diff --git a/BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs b/BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs index c8583bc..514d129 100644 --- a/BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs +++ b/BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs @@ -26,7 +26,12 @@ namespace MiniGames.Client.ViewModel public int GewinnerIndex { get { return Model.GewinnerIndex; } - set { Model.GewinnerIndex = value; } + set { + if (Model.GewinnerIndex < 0) + { + Model.GewinnerIndex = value; + } + } } public void SpielerInput(int posIndex) diff --git a/BlazorSolution/MiniGamesTests/TicTacToeTest.cs b/BlazorSolution/MiniGamesTests/TicTacToeTest.cs index e98daaa..9a43703 100644 --- a/BlazorSolution/MiniGamesTests/TicTacToeTest.cs +++ b/BlazorSolution/MiniGamesTests/TicTacToeTest.cs @@ -102,20 +102,20 @@ namespace MiniGamesTests Assert.Equal(erwarteterSpielerIndex, spiel.AktiverSpielerIndex); } - [Fact] - public void SpielerInput_GewinnerTest() + [Theory] + [InlineData(0, 0, 3, 1, 4, 2)] + [InlineData(0, 3, 0, 4, 1, 5, 2)] + public void SpielerInput_GewinnerTest(int gewinnerIndex, params int[] inputs) { // arrange TicTacToe spiel = StandardSpiel(); - spiel.AktiverSpielerIndex = 0; - int erwarteterGewinnerIndex = 0; + int erwarteterGewinnerIndex = gewinnerIndex; // act - spiel.SpielerInput(0); - spiel.SpielerInput(3); - spiel.SpielerInput(1); - spiel.SpielerInput(4); - spiel.SpielerInput(2); + foreach (int input in inputs) + { + spiel.SpielerInput(input); + } // assert Assert.Equal(spiel.GewinnerIndex, erwarteterGewinnerIndex);