1er essais
All checks were successful
check main state / build (8.0.x) (push) Successful in 1m42s
Main Build Process / Build & Test (pull_request) Successful in 2m12s

This commit is contained in:
2024-08-30 16:08:51 +02:00
parent b5a6b1c653
commit 4a5fc49c31
9 changed files with 213 additions and 16 deletions

View 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);
}
};
}
}

View 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()));
}
}