Browse Source

TicTacToe.SpielerInput-Test setzt Feldwert in Brett

feature/tictactoe
Felix Detig 2 years ago
parent
commit
486401d941
  1. 2
      BlazorSolution/MiniGames/Client/ViewModel/ITicTacToe.cs
  2. 4
      BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs
  3. 20
      BlazorSolution/MiniGamesTests/TicTacToeTest.cs

2
BlazorSolution/MiniGames/Client/ViewModel/ITicTacToe.cs

@ -2,6 +2,6 @@
{
public interface ITicTacToe
{
bool SpielerInput(int spielerIndex, int posIndex);
void SpielerInput(int posIndex);
}
}

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

@ -23,9 +23,9 @@ namespace MiniGames.Client.ViewModel
set { Model.AktiverSpielerIndex = value; }
}
public bool SpielerInput(int spielerIndex, int posIndex)
public void SpielerInput(int posIndex)
{
return true;
Brett.Set(posIndex, AktiverSpielerIndex);
}
public void SpielerWechsel()

20
BlazorSolution/MiniGamesTests/TicTacToeTest.cs

@ -58,5 +58,25 @@ namespace MiniGamesTests
// assert
Assert.Equal(erwarteterIndex, spiel.AktiverSpielerIndex);
}
[Fact]
public void SpielerInput_ValidesInputTest()
{
// arrange
TicTacToe spiel = StandardSpiel();
int pos = 2;
TicTacToeBrett erwartetesBrett = new(new int[,]
{
{ TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER, },
{ TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER, },
{ spiel.AktiverSpielerIndex, TicTacToeBrett.LEER, TicTacToeBrett.LEER, },
});
// act
spiel.SpielerInput(pos);
// assert
Assert.True(spiel.Brett.Gleich(erwartetesBrett));
}
}
}
Loading…
Cancel
Save