87 lines
2.7 KiB
C#
87 lines
2.7 KiB
C#
using NUnit.Framework;
|
|
|
|
using MultiversalDiplomacy.Model;
|
|
using MultiversalDiplomacy.Orders;
|
|
using MultiversalDiplomacy.Script;
|
|
|
|
namespace MultiversalDiplomacyTests;
|
|
|
|
public class ReplTest
|
|
{
|
|
[Test]
|
|
public void SetupHandler()
|
|
{
|
|
SetupScriptHandler setup = new(World.WithStandardMap(), strict: true);
|
|
ReplDriver repl = new(setup);
|
|
|
|
repl["""
|
|
unit Germany A Munich
|
|
unit Austria Army Tyrolia
|
|
unit England F Lon
|
|
"""].AssertReady();
|
|
|
|
Assert.That(repl.Handler, Is.TypeOf<SetupScriptHandler>());
|
|
SetupScriptHandler handler = (SetupScriptHandler)repl.Handler!;
|
|
Assert.That(handler.World.Units.Count, Is.EqualTo(3));
|
|
Assert.That(handler.World.GetUnitAt("Mun"), Is.Not.Null);
|
|
Assert.That(handler.World.GetUnitAt("Tyr"), Is.Not.Null);
|
|
Assert.That(handler.World.GetUnitAt("Lon"), Is.Not.Null);
|
|
|
|
repl["""
|
|
---
|
|
"""].AssertReady();
|
|
|
|
Assert.That(repl.Handler, Is.TypeOf<GameScriptHandler>());
|
|
}
|
|
|
|
[Test]
|
|
public void SubmitOrders()
|
|
{
|
|
SetupScriptHandler setup = new(World.WithStandardMap(), strict: true);
|
|
ReplDriver repl = new ReplDriver(setup)["""
|
|
unit Germany A Mun
|
|
unit Austria A Tyr
|
|
unit England F Lon
|
|
begin
|
|
"""];
|
|
|
|
repl["""
|
|
Germany A Mun hold
|
|
Austria: Army Tyrolia - Vienna
|
|
England:
|
|
Lon h
|
|
"""].AssertReady();
|
|
|
|
Assert.That(repl.Handler, Is.TypeOf<GameScriptHandler>());
|
|
GameScriptHandler handler = (GameScriptHandler)repl.Handler!;
|
|
Assert.That(handler.Orders.Count, Is.EqualTo(3));
|
|
Assert.That(handler.Orders.Single(o => o.Power == "Germany"), Is.TypeOf<HoldOrder>());
|
|
Assert.That(handler.Orders.Single(o => o.Power == "Austria"), Is.TypeOf<MoveOrder>());
|
|
Assert.That(handler.Orders.Single(o => o.Power == "England"), Is.TypeOf<HoldOrder>());
|
|
Assert.That(handler.World.Timelines.Pasts.Count, Is.EqualTo(1));
|
|
|
|
World before = handler.World;
|
|
|
|
repl["""
|
|
---
|
|
"""].AssertReady();
|
|
|
|
Assert.That(repl.Handler, Is.TypeOf<AdjudicationQueryScriptHandler>());
|
|
var newHandler = (AdjudicationQueryScriptHandler)repl.Handler!;
|
|
Assert.That(newHandler.World, Is.Not.EqualTo(before));
|
|
Assert.That(newHandler.World.Timelines.Pasts.Count, Is.EqualTo(2));
|
|
}
|
|
|
|
[Test]
|
|
public void AssertBasic()
|
|
{
|
|
var repl = new ReplDriver(new SetupScriptHandler(World.WithStandardMap(), strict: true))["""
|
|
unit Germany A Munich
|
|
---
|
|
---
|
|
"""];
|
|
repl["assert true"].AssertReady();
|
|
repl["assert false"].AssertClosed();
|
|
}
|
|
}
|