Browse Source

fixed TicTacToeBrett.Set (x und y vertauscht) und mehr Tests für TicTacToeBrett.Set

feature/tictactoe
Felix Detig 3 years ago
parent
commit
280c28c000
  1. 4
      BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs
  2. 40
      BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs

4
BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs

@ -65,8 +65,8 @@ namespace MiniGames.Shared.Models
public bool Set(int pos, int wert) public bool Set(int pos, int wert)
{ {
int x = pos / 3;
int y = pos % 3;
int x = pos % 3;
int y = pos / 3;
try try
{ {

40
BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs

@ -21,20 +21,38 @@ namespace MiniGamesTests
); );
} }
[Fact]
public void Set_FreiesFeldBelegenTest()
[Theory]
[InlineData(4, 0,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER,
TicTacToeBrett.LEER, 0
)]
[InlineData(0, 1,
1
)]
[InlineData(8, 2,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, 2
)]
[InlineData(6, 3,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, 3,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER
)]
[InlineData(3, 4,
TicTacToeBrett.LEER, 4, TicTacToeBrett.LEER,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER,
TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER
)]
public void Set_FreiesFeldBelegenTest(int pos, int wert,
int a = TicTacToeBrett.LEER, int b = TicTacToeBrett.LEER, int c = TicTacToeBrett.LEER,
int d = TicTacToeBrett.LEER, int e = TicTacToeBrett.LEER, int f = TicTacToeBrett.LEER,
int g = TicTacToeBrett.LEER, int h = TicTacToeBrett.LEER, int i = TicTacToeBrett.LEER
)
{ {
// arrange // arrange
TicTacToeBrett brett = new(); TicTacToeBrett brett = new();
TicTacToeBrett erwartetesBrett = TestBrett(
TicTacToeBrett.LEER,
TicTacToeBrett.LEER,
TicTacToeBrett.LEER,
TicTacToeBrett.LEER,
0
);
int pos = 4;
int wert = 0;
TicTacToeBrett erwartetesBrett = TestBrett(a, b, c, d, e, f, g, h, i);
bool erwartetGesetzt = true; bool erwartetGesetzt = true;
// act // act

Loading…
Cancel
Save