From 280c28c000bc139b5f712ed03601557c345aec41 Mon Sep 17 00:00:00 2001 From: Felix Detig Date: Mon, 14 Feb 2022 23:08:46 +0100 Subject: [PATCH] =?UTF-8?q?fixed=20TicTacToeBrett.Set=20(x=20und=20y=20ver?= =?UTF-8?q?tauscht)=20und=20mehr=20Tests=20f=C3=BCr=20TicTacToeBrett.Set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MiniGames/Shared/Models/TicTacToeBrett.cs | 4 +- .../MiniGamesTests/TicTacToeBrettTest.cs | 40 ++++++++++++++----- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs index 8f2ab97..68d1b0d 100644 --- a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs +++ b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs @@ -65,8 +65,8 @@ namespace MiniGames.Shared.Models public bool Set(int pos, int wert) { - int x = pos / 3; - int y = pos % 3; + int x = pos % 3; + int y = pos / 3; try { diff --git a/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs b/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs index 36ea54a..cb18287 100644 --- a/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs +++ b/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 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; // act