From 19fce551c09841ff6dcefc27ac9808e978c8c896 Mon Sep 17 00:00:00 2001 From: Felix Detig Date: Sat, 12 Feb 2022 14:56:53 +0100 Subject: [PATCH] TicTacToeBrett.Gewinner erkennt zweite volle vertikale Reihe --- .../MiniGames/Shared/Models/TicTacToeBrett.cs | 5 +++++ .../MiniGamesTests/TicTacToeBrettTest.cs | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs index 48a6800..006dfe1 100644 --- a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs +++ b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs @@ -87,6 +87,11 @@ namespace MiniGames.Shared.Models return Felder[0, 0]; } + if (Felder[1, 0] == Felder[1, 1] && Felder[1, 1] == Felder[1, 2] && Felder[1, 0] != LEER) + { + return Felder[1, 0]; + } + return LEER; } } diff --git a/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs b/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs index fd16442..cdf6d57 100644 --- a/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs +++ b/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs @@ -211,5 +211,22 @@ namespace MiniGamesTests // assert Assert.Equal(erwarteterGewinner, erhaltenerGewinner); } + + [Fact] + public void Gewinner_VertikaleReihe2Test() + { + // arrange + TicTacToeBrett brett = TestBrett( + TicTacToeBrett.LEER, TicTacToeBrett.LEER, TicTacToeBrett.LEER, + 0, 0, 0 + ); + int erwarteterGewinner = 0; + + // act + int erhaltenerGewinner = brett.Gewinner(); + + // assert + Assert.Equal(erwarteterGewinner, erhaltenerGewinner); + } } }