Browse Source

erster Test ob hand ist Stein erstellt

feature/scheresteinpapier
ADato88 3 years ago
parent
commit
c7e05acc43
  1. 24
      BlazorSolution/MiniGames/Client/ViewModel/SchereSteinPapierEchseSpock.cs
  2. 12
      BlazorSolution/MiniGames/Server/.config/dotnet-tools.json
  3. 27
      BlazorSolution/MiniGames/Shared/Models/SchereSteinPapierEchseSpockModel.cs
  4. 34
      BlazorSolution/MiniGamesTests/SchereSteinPapierEchseSpockTest.cs
  5. 14
      BlazorSolution/MiniGamesTests/UnitTest1.cs

24
BlazorSolution/MiniGames/Client/ViewModel/SchereSteinPapierEchseSpock.cs

@ -0,0 +1,24 @@
using MiniGames.Shared.Models;
using System;
namespace MiniGames.Client.ViewModel
{
public class SchereSteinPapierEchseSpock
{
SchereSteinPapierEchseSpockModel RegelModel = new();
public string SpielerStein(int hand, int gegner)
{
if(hand == 0 && (gegner == 1 || gegner == 3))
{
return RegelModel.erg[0].ToString();
} else if(hand == 0 && (gegner == 2 || gegner == 4))
{
return RegelModel.erg[1].ToString();
} else
{
return RegelModel.erg[2].ToString();
}
}
}
}

12
BlazorSolution/MiniGames/Server/.config/dotnet-tools.json

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "6.0.1",
"commands": [
"dotnet-ef"
]
}
}
}

27
BlazorSolution/MiniGames/Shared/Models/SchereSteinPapierEchseSpockModel.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MiniGames.Shared.Models
{
public class SchereSteinPapierEchseSpockModel
{
public string[] hand = new[]
{
"Stein",
"Papier",
"Schere",
"Echse",
"Spock"
};
public string[] erg = new[]
{
"Gewonnen",
"Verloren",
"Unentschieden"
};
}
}

34
BlazorSolution/MiniGamesTests/SchereSteinPapierEchseSpockTest.cs

@ -0,0 +1,34 @@
using MiniGames.Client.ViewModel;
using MiniGames.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace MiniGamesTests
{
public class SchereSteinPapierEchseSpockTest
{
SchereSteinPapierEchseSpock Spiel = new();
[Theory]
[InlineData(0, 0, "Unentschieden")]
public void IsStone(int hand, int gegnerHand, string erwartet)
{
//arrange
int handId = hand;
int gegnerId = gegnerHand;
string erwartetesErg = erwartet;
//act
string getestetesErg = Spiel.SpielerStein(handId, gegnerId);
//assert
Assert.Equal(erwartetesErg, getestetesErg);
}
}
}

14
BlazorSolution/MiniGamesTests/UnitTest1.cs

@ -1,14 +0,0 @@
using System;
using Xunit;
namespace MiniGamesTests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}
Loading…
Cancel
Save