Skip to content

Commit

Permalink
Merge pull request #3 from SP-SDU/feature-add-frontend-libraries
Browse files Browse the repository at this point in the history
Feature add frontend libraries
  • Loading branch information
RespectMathias authored Nov 3, 2024
2 parents 6206e16 + b77ac0c commit 6515604
Show file tree
Hide file tree
Showing 121 changed files with 83,010 additions and 971 deletions.
30 changes: 0 additions & 30 deletions .dockerignore

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
.idea/

# Ignore macOS system files
.DS_Store

# Ignore secrets
.env
15 changes: 0 additions & 15 deletions Directory.Build.props

This file was deleted.

89 changes: 89 additions & 0 deletions GameLibrary.Tests/ErrorModelTests.cs
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);
}
}
25 changes: 0 additions & 25 deletions GameLibrary.Tests/UnitTest1.cs

This file was deleted.

8 changes: 0 additions & 8 deletions GameLibrary.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameLibrary", "GameLibrary\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{32529449-CB26-44FA-BABF-25EB74EC60C9}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
.editorconfig = .editorconfig
.gitignore = .gitignore
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
Directory.Build.props = Directory.Build.props
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameLibrary.Tests", "GameLibrary.Tests\GameLibrary.Tests.csproj", "{00DBE095-DE0F-4A21-B7EC-F9EE500BDECC}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{25E0EFCC-7F47-4A14-9000-C8DAB6461F6F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,10 +30,6 @@ Global
{00DBE095-DE0F-4A21-B7EC-F9EE500BDECC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00DBE095-DE0F-4A21-B7EC-F9EE500BDECC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00DBE095-DE0F-4A21-B7EC-F9EE500BDECC}.Release|Any CPU.Build.0 = Release|Any CPU
{25E0EFCC-7F47-4A14-9000-C8DAB6461F6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25E0EFCC-7F47-4A14-9000-C8DAB6461F6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25E0EFCC-7F47-4A14-9000-C8DAB6461F6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25E0EFCC-7F47-4A14-9000-C8DAB6461F6F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
31 changes: 0 additions & 31 deletions GameLibrary/Dockerfile

This file was deleted.

6 changes: 1 addition & 5 deletions GameLibrary/GameLibrary.csproj
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>
38 changes: 20 additions & 18 deletions GameLibrary/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 PET Group
// Copyright 2024 Web.Tech. Group17
//
// Licensed under the Apache License, Version 2.0 (the "License"):
// you may not use this file except in compliance with the License.
Expand All @@ -12,27 +12,29 @@
// See the License for the specific language governing permissions and
// limitations under the License.

namespace GameLibrary.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
namespace GameLibrary.Pages;

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

private readonly ILogger<ErrorModel> _logger;
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
private readonly ILogger<ErrorModel> _logger;

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
26 changes: 14 additions & 12 deletions GameLibrary/Pages/Index.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 PET Group
// Copyright 2024 Web.Tech. Group17
//
// Licensed under the Apache License, Version 2.0 (the "License"):
// you may not use this file except in compliance with the License.
Expand All @@ -12,20 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

namespace GameLibrary.Pages
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace GameLibrary.Pages;

public class IndexModel : PageModel
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly ILogger<IndexModel> _logger;

public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}
public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}

public void OnGet()
{
public void OnGet()
{

}
}
}
27 changes: 14 additions & 13 deletions GameLibrary/Pages/Privacy.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 PET Group
// Copyright 2024 Web.Tech. Group17
//
// Licensed under the Apache License, Version 2.0 (the "License"):
// you may not use this file except in compliance with the License.
Expand All @@ -12,20 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

namespace GameLibrary.Pages
{
public class PrivacyModel : PageModel
{
private readonly ILogger<PrivacyModel> _logger;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

public PrivacyModel(ILogger<PrivacyModel> logger)
{
_logger = logger;
}
namespace GameLibrary.Pages;

public class PrivacyModel : PageModel
{
private readonly ILogger<PrivacyModel> _logger;

public void OnGet()
{
}
public PrivacyModel(ILogger<PrivacyModel> logger)
{
_logger = logger;
}

public void OnGet()
{
}
}
Loading

0 comments on commit 6515604

Please sign in to comment.