-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from SP-SDU/feature-add-frontend-libraries
Feature add frontend libraries
- Loading branch information
Showing
121 changed files
with
83,010 additions
and
971 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright 2024 PET Group16 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"): | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using System.Diagnostics; | ||
using GameLibrary.Pages; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace GameLibrary.Tests; | ||
|
||
public class ErrorModelTests | ||
{ | ||
[Fact] | ||
public void OnGet_SetsRequestId_FromHttpContext() | ||
{ | ||
// Arrange | ||
var mockLogger = new Mock<ILogger<ErrorModel>>(); | ||
var errorModel = new ErrorModel(mockLogger.Object); | ||
var httpContext = new DefaultHttpContext | ||
{ | ||
TraceIdentifier = "TestTraceId123" | ||
}; | ||
errorModel.PageContext = new PageContext() | ||
{ | ||
HttpContext = httpContext | ||
}; | ||
|
||
// Act | ||
errorModel.OnGet(); | ||
|
||
// Assert | ||
Assert.Equal("TestTraceId123", errorModel.RequestId); | ||
Assert.True(errorModel.ShowRequestId); | ||
} | ||
|
||
[Fact] | ||
public void OnGet_SetsRequestId_FromActivity() | ||
{ | ||
// Arrange | ||
var mockLogger = new Mock<ILogger<ErrorModel>>(); | ||
var errorModel = new ErrorModel(mockLogger.Object); | ||
var activity = new Activity("TestActivity"); | ||
_ = activity.Start(); | ||
|
||
// Act | ||
errorModel.OnGet(); | ||
activity.Stop(); | ||
|
||
// Assert | ||
Assert.Equal(activity.Id, errorModel.RequestId); | ||
Assert.True(errorModel.ShowRequestId); | ||
} | ||
|
||
[Fact] | ||
public void OnGet_SetsRequestId_FromFallback() | ||
{ | ||
// Arrange | ||
var mockLogger = new Mock<ILogger<ErrorModel>>(); | ||
var errorModel = new ErrorModel(mockLogger.Object); | ||
var httpContext = new DefaultHttpContext | ||
{ | ||
TraceIdentifier = string.Empty | ||
}; | ||
errorModel.PageContext = new PageContext() | ||
{ | ||
HttpContext = httpContext | ||
}; | ||
|
||
// Act | ||
errorModel.OnGet(); | ||
|
||
// Assert | ||
Assert.Equal(string.Empty, errorModel.RequestId); | ||
Assert.False(errorModel.ShowRequestId); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UserSecretsId>1dd8de4c-d8e8-4d9e-91f4-fcc04acba218</UserSecretsId> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-rc.2.24474.1" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-rc.2.24474.1" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.