Browse Source

TicTacToe.SpielerInput wechselt nur bei validem Input den Spieler

feature/tictactoe
Felix Detig 2 years ago
parent
commit
177c717f4a
  1. 6
      BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs
  2. 19
      BlazorSolution/MiniGamesTests/TicTacToeTest.cs

6
BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs

@ -25,8 +25,10 @@ namespace MiniGames.Client.ViewModel
public void SpielerInput(int posIndex)
{
Brett.Set(posIndex, AktiverSpielerIndex);
SpielerWechsel();
if (Brett.Set(posIndex, AktiverSpielerIndex))
{
SpielerWechsel();
}
}
public void SpielerWechsel()

19
BlazorSolution/MiniGamesTests/TicTacToeTest.cs

@ -82,5 +82,24 @@ namespace MiniGamesTests
Assert.True(spiel.Brett.Gleich(erwartetesBrett));
Assert.Equal(erwarteterSpielerIndex, spiel.AktiverSpielerIndex);
}
[Fact]
public void SpielerInput_InvalidesInputTest()
{
// arrange
TicTacToe spiel = StandardSpiel();
spiel.AktiverSpielerIndex = 0;
int erwarteterSpielerIndex = 0;
int pos = -1;
TicTacToeBrett erwartetesBrett = StandardBrett();
// act
spiel.SpielerInput(pos);
// assert
Assert.True(spiel.Brett.Gleich(erwartetesBrett));
Assert.Equal(erwarteterSpielerIndex, spiel.AktiverSpielerIndex);
}
}
}
Loading…
Cancel
Save