diff --git a/Koogle.Tests/GameTraining/GameTrainingServiceTest.cs b/Koogle.Tests/GameTraining/GameTrainingServiceTest.cs new file mode 100644 index 0000000..9597d29 --- /dev/null +++ b/Koogle.Tests/GameTraining/GameTrainingServiceTest.cs @@ -0,0 +1,66 @@ +using Fluxor; +using KoogleApp.Games; +using KoogleApp.Games.Training; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FluentAssertions; +using KoogleApp.Store.Game.ThrowPanel; +using Moq; + +namespace Koogle.Tests.GameTraining +{ + public class GameTrainingServiceTest + { + + private readonly ServiceProvider _serviceProvider; + private readonly Mock _mockDispatcher; + + public GameTrainingServiceTest() + { + var services = new ServiceCollection(); + + // Deine Services registrieren wie in Program.cs + services.AddScoped(); + //services.AddSingleton(new ConfigurationBuilder() + // .AddInMemoryCollection(new Dictionary + // { + // ["Setting"] = "TestValue" + // }) + // .Build()); + + _serviceProvider = services.BuildServiceProvider(); + + _mockDispatcher = new Mock(); + } + + [Fact] + public void ServiceWorksCorrectly() + { + // Arrange + var service = _serviceProvider.GetRequiredService(); + + // Act & Assert + var result = service.InitGameModel(GetSetup(), _mockDispatcher.Object) as TrainingGameModel; + result.Throws.Count.Should().Be(3); + } + + private IGameSetupModel GetSetup() + { + return new TrainingSetupState() + { + DayId = 1, + ThrowMode = ThrowMode.Reposition, + ThrowsPerRound = 3, + Participants = new int[] { 1, 2, 3 }, + ParticipantsMode = ParticipantsMode.GameLogic, + KnownGameType = "Training" + }; + } + } + +} diff --git a/Koogle.Tests/Koogle.Tests.csproj b/Koogle.Tests/Koogle.Tests.csproj new file mode 100644 index 0000000..09fe7cd --- /dev/null +++ b/Koogle.Tests/Koogle.Tests.csproj @@ -0,0 +1,27 @@ + + + + net9.0 + enable + enable + false + + + + + + + + + + + + + + + + + + + + diff --git a/Koogle.Tests/ReducerTests/ThrowPanelStateTests.cs b/Koogle.Tests/ReducerTests/ThrowPanelStateTests.cs new file mode 100644 index 0000000..e9e03bc --- /dev/null +++ b/Koogle.Tests/ReducerTests/ThrowPanelStateTests.cs @@ -0,0 +1,43 @@ +using KoogleApp.Components.Controls; +using KoogleApp.Games.Training; +using KoogleApp.Store.Game.ThrowPanel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FluentAssertions; + +namespace Koogle.Tests.ReducerTests +{ + public class ThrowPanelStateTests + { + [Fact] + public void StartStopAction_StartAGame() + { + // Arrange + var initialState = new ThrowPanelState(); + var action = new StartStopAction(initialState, new TrainingSetupState()); + + // Act + var newState = ThrowPanelStateReducer.OnStartStop(initialState, action); + + // Assert + newState.IsStated.Should().Be(true); + } + + [Fact] + public void StartStopAction_StopAGame() + { + // Arrange + var initialState = new ThrowPanelState(); + var action = new StartStopAction(initialState, null); + + // Act + var newState = ThrowPanelStateReducer.OnStartStop(initialState, action); + + // Assert + newState.IsStated.Should().Be(false); + } + } +} diff --git a/Koogle.Tests/UnitTest1.cs b/Koogle.Tests/UnitTest1.cs new file mode 100644 index 0000000..c1d316a --- /dev/null +++ b/Koogle.Tests/UnitTest1.cs @@ -0,0 +1,11 @@ +namespace Koogle.Tests +{ + //public class UnitTest1 + //{ + // [Fact] + // public void Test1() + // { + + // } + //} +} diff --git a/KoogleApp.sln b/KoogleApp.sln index 95ff083..2f80011 100644 --- a/KoogleApp.sln +++ b/KoogleApp.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.14.36401.2 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KoogleApp", "KoogleApp\KoogleApp.csproj", "{6D7E3614-968D-41F5-AD44-84E06C244859}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Koogle.Tests", "Koogle.Tests\Koogle.Tests.csproj", "{0940F5B5-C1FF-4B2C-8E1C-6F1D28BDAD7F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {6D7E3614-968D-41F5-AD44-84E06C244859}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D7E3614-968D-41F5-AD44-84E06C244859}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D7E3614-968D-41F5-AD44-84E06C244859}.Release|Any CPU.Build.0 = Release|Any CPU + {0940F5B5-C1FF-4B2C-8E1C-6F1D28BDAD7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0940F5B5-C1FF-4B2C-8E1C-6F1D28BDAD7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0940F5B5-C1FF-4B2C-8E1C-6F1D28BDAD7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0940F5B5-C1FF-4B2C-8E1C-6F1D28BDAD7F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE