From 6edb20d9e4c82b39a4142d89e21ea20244ca94df Mon Sep 17 00:00:00 2001 From: Felix Detig Date: Sat, 12 Feb 2022 01:00:47 +0100 Subject: [PATCH] TicTacToeBrett.Gewinner erkennt erste volle vertikale Reihe --- .../MiniGames/Shared/Models/TicTacToeBrett.cs | 5 +++++ .../MiniGamesTests/TicTacToeBrettTest.cs | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs index 6edae49..46142a5 100644 --- a/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs +++ b/BlazorSolution/MiniGames/Shared/Models/TicTacToeBrett.cs @@ -81,6 +81,11 @@ namespace MiniGames.Shared.Models public int Gewinner() { + if (Felder[0, 0] == Felder[0, 1] && Felder[0, 1] == Felder[0, 2] && Felder[0, 0] != LEER) + { + return Felder[0, 0]; + } + return LEER; } } diff --git a/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs b/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs index 1985467..fd16442 100644 --- a/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs +++ b/BlazorSolution/MiniGamesTests/TicTacToeBrettTest.cs @@ -197,5 +197,19 @@ namespace MiniGamesTests // assert Assert.Equal(erwarteterGewinner, erhaltenerGewinner); } + + [Fact] + public void Gewinner_VertikaleReihe1Test() + { + // arrange + TicTacToeBrett brett = TestBrett(0, 0, 0); + int erwarteterGewinner = 0; + + // act + int erhaltenerGewinner = brett.Gewinner(); + + // assert + Assert.Equal(erwarteterGewinner, erhaltenerGewinner); + } } }