Browse Source

Grundgerüst + naiver SpielerInput Test

feature/tictactoe
Felix Detig 2 years ago
parent
commit
555c265fe1
  1. 7
      BlazorSolution/MiniGames/Client/ViewModel/ITicTacToe.cs
  2. 19
      BlazorSolution/MiniGames/Client/ViewModel/TicTacToe.cs
  3. 14
      BlazorSolution/MiniGames/Shared/Models/TicTacToeModel.cs
  4. 66
      BlazorSolution/MiniGamesTests/TicTacToeTest.cs

7
BlazorSolution/MiniGames/Client/ViewModel/ITicTacToe.cs

@ -0,0 +1,7 @@
namespace MiniGames.Client.ViewModel
{
public interface ITicTacToe
{
bool SpielerInput(int spielerIndex, int posIndex);
}
}

19
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;
}
}
}

14
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; }
}
}

66
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);
}
}
}
Loading…
Cancel
Save