Updated build target to dotnet 12. Fixed failed tests and runtime failures

This commit is contained in:
Martin Berg Alstad 2023-12-10 15:39:26 +01:00
parent 9991bac6fa
commit 3e424a127e
10 changed files with 22 additions and 33 deletions

View File

@ -1,5 +1,6 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

View File

@ -10,8 +10,7 @@ using pacMan.Services;
namespace BackendTests.Services;
[TestFixture]
[TestOf(nameof(ActionService))]
[TestFixture, TestOf(nameof(ActionService))]
public class ActionServiceTests
{
[SetUp]
@ -157,7 +156,7 @@ public class ActionServiceTests
public void FindNextPlayer_NoPlayers()
{
_service.Game = new pacMan.Services.Game(new Queue<DirectionalPosition>());
Assert.Throws<InvalidOperationException>(() => _service.FindNextPlayer());
Assert.Throws<PlayerNotFoundException>(() => _service.FindNextPlayer());
}
[Test]

View File

@ -6,8 +6,7 @@ using pacMan.Utils;
namespace BackendTests.Services;
[TestFixture]
[TestOf(nameof(pacMan.Services.Game))]
[TestFixture, TestOf(nameof(pacMan.Services.Game))]
public class GameTests
{
[SetUp]
@ -56,7 +55,7 @@ public class GameTests
[Test]
public void NextPlayer_WhenEmpty()
{
Assert.Throws<InvalidOperationException>(() => _game.NextPlayer());
Assert.Throws<PlayerNotFoundException>(() => _game.NextPlayer());
}
[Test]

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>DAL</RootNamespace>

View File

@ -5,11 +5,9 @@ using pacMan.GameStuff.Items;
namespace pacMan.DTOs;
public readonly record struct JoinGameData(
[property: JsonInclude]
[property: JsonPropertyName("username")]
[property: JsonInclude, JsonPropertyName("username"), JsonRequired]
string Username,
[property: JsonInclude]
[property: JsonPropertyName("gameId")]
[property: JsonInclude, JsonPropertyName("gameId"), JsonRequired]
Guid GameId
)
{
@ -17,34 +15,26 @@ public readonly record struct JoinGameData(
}
public readonly record struct CreateGameData(
[property: JsonInclude]
[property: JsonPropertyName("player")]
[property: JsonInclude, JsonPropertyName("player"), JsonRequired]
Player Player,
[property: JsonInclude]
[property: JsonPropertyName("spawns")]
[property: JsonInclude, JsonPropertyName("spawns"), JsonRequired]
Queue<DirectionalPosition> Spawns
);
public readonly record struct ReadyData(
[property: JsonInclude]
[property: JsonPropertyName("allReady")]
[property: JsonInclude, JsonPropertyName("allReady"), JsonRequired]
bool AllReady,
[property: JsonInclude]
[property: JsonPropertyName("players")]
[property: JsonInclude, JsonPropertyName("players"), JsonRequired]
IEnumerable<Player> Players
);
public readonly record struct MovePlayerData(
[property: JsonInclude]
[property: JsonPropertyName("players")]
[property: JsonInclude, JsonPropertyName("players"), JsonRequired]
List<Player> Players,
[property: JsonInclude]
[property: JsonPropertyName("ghosts")]
[property: JsonInclude, JsonPropertyName("ghosts"), JsonRequired]
List<Character> Ghosts,
[property: JsonInclude]
[property: JsonPropertyName("dice")]
[property: JsonInclude, JsonPropertyName("dice"), JsonRequired]
List<int> Dice,
[property: JsonInclude]
[property: JsonPropertyName("eatenPellets")]
[property: JsonInclude, JsonPropertyName("eatenPellets"), JsonRequired]
List<Position> EatenPellets
);

View File

@ -24,7 +24,7 @@ public interface IActionService
/// <summary>
/// Provides various actions that can be performed in a game
/// </summary>
public class ActionService(ILogger logger, IGameService gameService) : IActionService
public class ActionService(ILogger<ActionService> logger, IGameService gameService) : IActionService
{
public WebSocket WebSocket { private get; set; } = null!;

View File

@ -17,7 +17,7 @@ public interface IGameService : IWebSocketService
/// The GameService class provides functionality for managing games in a WebSocket environment. It inherits from the
/// WebSocketService class.
/// </summary>
public class GameService(ILogger logger) : WebSocketService(logger), IGameService
public class GameService(ILogger<WebSocketService> logger) : WebSocketService(logger), IGameService
{
/// <summary>
/// A thread-safe collection (SynchronizedCollection) of "Game" objects. Utilized for managing multiple game instances

View File

@ -13,7 +13,7 @@ public interface IWebSocketService
/// <summary>
/// WebSocketService class provides methods to send, receive and close a WebSocket connection.
/// </summary>
public class WebSocketService(ILogger logger) : IWebSocketService
public class WebSocketService(ILogger<WebSocketService> logger) : IWebSocketService
{
/// <summary>
/// Sends the specified byte array as a text message through the WebSocket connection.

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>