1er essais
This commit is contained in:
36
src/LittleTown.Core.Tests/MatchUpdaterTesting.cs
Normal file
36
src/LittleTown.Core.Tests/MatchUpdaterTesting.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using LittleTown.Core.Actions;
|
||||
using LittleTown.StaticDataAcces;
|
||||
|
||||
namespace LittleTown.Core.Tests;
|
||||
|
||||
public class MatchUpdaterTesting
|
||||
{
|
||||
private class TestAction : IAction
|
||||
{
|
||||
public Action<MatchUpdater> CB { get; init; } = delegate { };
|
||||
|
||||
public void Execute(MatchUpdater updater)
|
||||
{
|
||||
CB(updater);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnforcePlayerCountInMatchCreation()
|
||||
{
|
||||
StaticDataGetter getter = new StaticDataGetter();
|
||||
|
||||
Match match = new Match(getter);
|
||||
match.AddPlayer("Player1");
|
||||
match.AddPlayer("Player2");
|
||||
match.Init();
|
||||
|
||||
TestAction ta = new TestAction()
|
||||
{
|
||||
CB = (updater) =>
|
||||
{
|
||||
Assert.True(updater.GetMatch() == match);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
34
src/LittleTown.Core.Tests/MatchWorkflowTesting.cs
Normal file
34
src/LittleTown.Core.Tests/MatchWorkflowTesting.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using LittleTown.Core.Actions;
|
||||
using LittleTown.Core.Exceptions;
|
||||
using LittleTown.StaticDataAcces;
|
||||
|
||||
namespace LittleTown.Core.Tests;
|
||||
|
||||
public class MatchWorkflowTesting
|
||||
{
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Simple2PlayerGame()
|
||||
{
|
||||
StaticDataGetter getter = new StaticDataGetter();
|
||||
|
||||
Match match = new Match(getter);
|
||||
match.AddPlayer("Player1");
|
||||
match.AddPlayer("Player2");
|
||||
match.Init();
|
||||
|
||||
int count = 0;
|
||||
while (!match.IsDone)
|
||||
{
|
||||
EmptyAction action = new EmptyAction();
|
||||
match.ExecuteAction(action);
|
||||
count++;
|
||||
if (count > 40)
|
||||
{
|
||||
Assert.Fail("Trop d'action pour une partie vide");
|
||||
}
|
||||
}
|
||||
Assert.Throws<MatchFinishedException>(() => match.ExecuteAction(new EmptyAction()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user