Add DATC 6.A.* test cases
For now, just the parts that can be decided with validation are run. The tests and parts of tests requiring movement adjudication will be implemented fully when movement adjudication is implemented.
This commit is contained in:
parent
8c828661e2
commit
697614e34f
@ -89,7 +89,7 @@ internal static class AdjudicatorHelpers
|
||||
_ => true,
|
||||
},
|
||||
ValidationReason.InvalidUnitForPower,
|
||||
ref orders,
|
||||
ref validOrders,
|
||||
ref invalidOrders);
|
||||
}
|
||||
}
|
||||
|
187
MultiversalDiplomacyTests/DATC_A.cs
Normal file
187
MultiversalDiplomacyTests/DATC_A.cs
Normal file
@ -0,0 +1,187 @@
|
||||
using MultiversalDiplomacy.Adjudicate;
|
||||
using MultiversalDiplomacy.Model;
|
||||
using MultiversalDiplomacy.Orders;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MultiversalDiplomacyTests;
|
||||
|
||||
public class DATC_A
|
||||
{
|
||||
private World StandardEmpty { get; } = World.WithStandardMap().WithInitialSeason();
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_1_MoveToAnAreaThatIsNotANeighbor()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup["England"]
|
||||
.Fleet("North Sea").MovesTo("Picardy").GetReference(out var order);
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(order.Validation, Is.Invalid(ValidationReason.UnreachableDestination));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_2_MoveArmyToSea()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
|
||||
Assert.That(
|
||||
() =>
|
||||
{
|
||||
setup["England"]
|
||||
.Army("Liverpool").MovesTo("Irish Sea");
|
||||
},
|
||||
Throws.TypeOf<KeyNotFoundException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_3_MoveFleetToLand()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
|
||||
Assert.That(
|
||||
() =>
|
||||
{
|
||||
setup["Germany"]
|
||||
.Fleet("Kiel").MovesTo("Munich");
|
||||
},
|
||||
Throws.TypeOf<KeyNotFoundException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_4_MoveToOwnSector()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup["Germany"]
|
||||
.Fleet("Kiel").MovesTo("Kiel").GetReference(out var order);
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(order.Validation, Is.Invalid(ValidationReason.DestinationMatchesOrigin));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_5_MoveToOwnSectorWithConvoy()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["England"]
|
||||
.Fleet("North Sea").Convoys.Army("Yorkshire").To("Yorkshire").GetReference(out var orderNth)
|
||||
.Army("Yorkshire").MovesTo("Yorkshire").GetReference(out var orderYor)
|
||||
.Army("Liverpool").Supports.Army("Yorkshire").MoveTo("Yorkshire")
|
||||
["Germany"]
|
||||
.Fleet("London").MovesTo("Yorkshire")
|
||||
.Army("Wales").Supports.Fleet("London").MoveTo("Yorkshire");
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(orderNth.Validation, Is.Invalid(ValidationReason.DestinationMatchesOrigin));
|
||||
Assert.That(orderYor.Validation, Is.Invalid(ValidationReason.DestinationMatchesOrigin));
|
||||
|
||||
// TODO assert dislodge
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_6_OrderingAUnitOfAnotherCountry()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["Germany"]
|
||||
.Fleet("London", powerName: "England").MovesTo("North Sea").GetReference(out var order);
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(order.Validation, Is.Invalid(ValidationReason.InvalidUnitForPower));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_7_OnlyArmiesCanBeConvoyed()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["England"]
|
||||
.Fleet("London").MovesTo("Belgium")
|
||||
.Fleet("North Sea").Convoys.Army("London").To("Belgium").GetReference(out var order);
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(order.Validation, Is.Invalid(ValidationReason.InvalidOrderTypeForUnit));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_8_SupportToHoldYourselfIsNotPossible()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["Italy"]
|
||||
.Army("Venice").MovesTo("Trieste")
|
||||
.Army("Tyrolia").Supports.Army("Venice").MoveTo("Trieste")
|
||||
["Austria"]
|
||||
.Fleet("Trieste").Supports.Fleet("Trieste").Hold().GetReference(out var order);
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(order.Validation, Is.Invalid(ValidationReason.NoSelfSupport));
|
||||
|
||||
// TODO assert dislodge
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_9_FleetsMustFollowCoastIfNotOnSea()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["Italy"]
|
||||
.Fleet("Rome").MovesTo("Venice").GetReference(out var order);
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(order.Validation, Is.Invalid(ValidationReason.UnreachableDestination));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DATC_6_A_10_SupportOnUnreachableDestinationNotPossible()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["Austria"]
|
||||
.Army("Venice").Holds()
|
||||
["Italy"]
|
||||
.Army("Apulia").MovesTo("Venice")
|
||||
.Fleet("Rome").Supports.Army("Apulia").MoveTo("Venice").GetReference(out var order);
|
||||
|
||||
setup.ValidateOrders(new MovementPhaseAdjudicator());
|
||||
|
||||
Assert.That(order.Validation, Is.Invalid(ValidationReason.UnreachableSupport));
|
||||
|
||||
// TODO assert dislodge
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("TODO")]
|
||||
public void DATC_6_A_11_SimpleBounce()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["Austria"]
|
||||
.Army("Vienna").MovesTo("Tyrolia")
|
||||
["Italy"]
|
||||
.Army("Venice").MovesTo("Tyrolia");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("TODO")]
|
||||
public void DATC_6_A_12_BounceOfThreeUnits()
|
||||
{
|
||||
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
||||
setup
|
||||
["Austria"]
|
||||
.Army("Vienna").MovesTo("Tyrolia")
|
||||
["Germany"]
|
||||
.Army("Munich").MovesTo("Tyrolia")
|
||||
["Italy"]
|
||||
.Army("Venice").MovesTo("Tyrolia");
|
||||
}
|
||||
}
|
@ -24,12 +24,12 @@ public class TestCaseBuilder
|
||||
/// <summary>
|
||||
/// Define an order for an army in a province.
|
||||
/// </summary>
|
||||
public IUnitContext Army(string provinceName);
|
||||
public IUnitContext Army(string provinceName, string? powerName = null);
|
||||
|
||||
/// <summary>
|
||||
/// Define an order for a fleet in a province, optionally on a specific coast.
|
||||
/// </summary>
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null);
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null, string? powerName = null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -143,12 +143,12 @@ public class TestCaseBuilder
|
||||
/// <summary>
|
||||
/// Define an order for a new army in a province.
|
||||
/// </summary>
|
||||
public IUnitContext Army(string provinceName);
|
||||
public IUnitContext Army(string provinceName, string? powerName = null);
|
||||
|
||||
/// <summary>
|
||||
/// Define an order for a new fleet in a province, optionally on a specific coast.
|
||||
/// </summary>
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null);
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null, string? powerName = null);
|
||||
|
||||
/// <summary>
|
||||
/// Save a reference to the order just defined.
|
||||
@ -206,7 +206,7 @@ public class TestCaseBuilder
|
||||
foreach (Unit unit in this.World.Units)
|
||||
{
|
||||
if (unit.Power == power
|
||||
&& unit.Location == location
|
||||
&& unit.Location.Province == location.Province
|
||||
&& unit.Season == season)
|
||||
{
|
||||
return unit;
|
||||
@ -239,19 +239,25 @@ public class TestCaseBuilder
|
||||
public IPowerContext this[string powerName]
|
||||
=> this.Builder[powerName];
|
||||
|
||||
public IUnitContext Army(string provinceName)
|
||||
public IUnitContext Army(string provinceName, string? powerName = null)
|
||||
{
|
||||
Power power = powerName == null
|
||||
? this.Power
|
||||
: this.Builder.World.GetPower(powerName);
|
||||
Location location = this.Builder.World.GetLand(provinceName);
|
||||
Unit unit = this.Builder.GetOrBuildUnit(
|
||||
this.Power, location, this.Builder.Season, UnitType.Army);
|
||||
power, location, this.Builder.Season, UnitType.Army);
|
||||
return new UnitContext(this, unit);
|
||||
}
|
||||
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null)
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null, string? powerName = null)
|
||||
{
|
||||
Power power = powerName == null
|
||||
? this.Power
|
||||
: this.Builder.World.GetPower(powerName);
|
||||
Location location = this.Builder.World.GetWater(provinceName, coast);
|
||||
Unit unit = this.Builder.GetOrBuildUnit(
|
||||
this.Power, location, this.Builder.Season, UnitType.Fleet);
|
||||
power, location, this.Builder.Season, UnitType.Fleet);
|
||||
return new UnitContext(this, unit);
|
||||
}
|
||||
}
|
||||
@ -474,10 +480,11 @@ public class TestCaseBuilder
|
||||
|
||||
public IPowerContext this[string powerName] => this.PowerContext[powerName];
|
||||
|
||||
public IUnitContext Army(string provinceName) => this.PowerContext.Army(provinceName);
|
||||
public IUnitContext Army(string provinceName, string? powerName = null)
|
||||
=> this.PowerContext.Army(provinceName, powerName);
|
||||
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null)
|
||||
=> this.PowerContext.Fleet(provinceName);
|
||||
public IUnitContext Fleet(string provinceName, string? coast = null, string? powerName = null)
|
||||
=> this.PowerContext.Fleet(provinceName, coast, powerName);
|
||||
|
||||
public IOrderDefinedContext<OrderType> GetReference(out OrderReference<OrderType> order)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user