diff --git a/BlazorSolution/MiniGames/Client/ViewModel/ITicTacToe.cs b/BlazorSolution/MiniGames/Client/ViewModel/ITicTacToe.cs new file mode 100644 index 0000000..6d9794a --- /dev/null +++ b/BlazorSolution/MiniGames/Client/ViewModel/ITicTacToe.cs @@ -0,0 +1,7 @@ +namespace MiniGames.Client.ViewModel +{ + public interface ITicTacToe + { + bool SpielerInput(int spielerIndex, int posIndex); + } +} diff --git a/BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs b/BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs new file mode 100644 index 0000000..2de9f08 --- /dev/null +++ b/BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs @@ -0,0 +1,19 @@ +using MiniGames.Shared.Models; + +namespace MiniGames.Client.ViewModel +{ + public class TicTacToe : ITicTacToe + { + TicTacToeModel Model; + + public TicTacToe(TicTacToeModel model) + { + this.Model = model; + } + + public bool SpielerInput(int spielerIndex, int posIndex) + { + return true; + } + } +} diff --git a/BlazorSolution/MiniGames/Shared/Models/TicTacToeModel.cs b/BlazorSolution/MiniGames/Shared/Models/TicTacToeModel.cs new file mode 100644 index 0000000..90b4e27 --- /dev/null +++ b/BlazorSolution/MiniGames/Shared/Models/TicTacToeModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MiniGames.Shared.Models +{ + public class TicTacToeModel + { + public SpielerModel[] Spieler { get; set; } + public int[,] Karte { get; set; } + } +} diff --git a/BlazorSolution/MiniGamesTests/TicTacToeTest.cs b/BlazorSolution/MiniGamesTests/TicTacToeTest.cs new file mode 100644 index 0000000..8d4a7e5 --- /dev/null +++ b/BlazorSolution/MiniGamesTests/TicTacToeTest.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +using MiniGames.Shared.Models; +using MiniGames.Client.ViewModel; + +namespace MiniGamesTests +{ + public class TicTacToeTest + { + int[,] StandardKarte() + { + return new int[,] + { + { -1, -1, -1, }, + { -1, -1, -1, }, + { -1, -1, -1, }, + }; + } + + SpielerModel[] StandardSpieler() + { + return new SpielerModel[] + { + new SpielerModel + { + SpielerName = "Spieler 1", + Punkte = 0 + }, + new SpielerModel + { + SpielerName = "Spieler 2", + Punkte = 1 + } + }; + } + + TicTacToeModel StandardModel() + { + return new TicTacToeModel + { + Spieler = StandardSpieler(), + Karte = StandardKarte(), + }; + } + + [Theory] + [InlineData(0, 4, true)] + private void SpielerInput_FreiesFeldBelegenTest(int spielerIndex, int posIndex, bool gesetzt) + { + // arrange + TicTacToe spiel = new(StandardModel()); + bool erwartetGesetzt = gesetzt; + + // act + bool erhaltenGesetzt = spiel.SpielerInput(spielerIndex, posIndex); + + // assert + Assert.Equal(erwartetGesetzt, erhaltenGesetzt); + } + } +}