2022-03-23 06:16:02 +00:00
|
|
|
using MultiversalDiplomacy.Adjudicate;
|
|
|
|
using MultiversalDiplomacy.Model;
|
2022-03-28 22:05:04 +00:00
|
|
|
using MultiversalDiplomacy.Orders;
|
2022-03-23 06:16:02 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
|
2024-08-28 21:27:35 +00:00
|
|
|
using static MultiversalDiplomacyTests.Adjudicator;
|
|
|
|
|
2022-03-23 06:16:02 +00:00
|
|
|
namespace MultiversalDiplomacyTests;
|
|
|
|
|
|
|
|
public class DATC_A
|
|
|
|
{
|
2022-03-29 05:34:57 +00:00
|
|
|
private World StandardEmpty { get; } = World.WithStandardMap();
|
2022-03-23 06:16:02 +00:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void DATC_6_A_1_MoveToAnAreaThatIsNotANeighbor()
|
|
|
|
{
|
|
|
|
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
|
|
|
setup["England"]
|
|
|
|
.Fleet("North Sea").MovesTo("Picardy").GetReference(out var order);
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Order should fail.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(order, Is.Invalid(ValidationReason.UnreachableDestination));
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void DATC_6_A_2_MoveArmyToSea()
|
|
|
|
{
|
|
|
|
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Order should fail.
|
2022-03-23 06:16:02 +00:00
|
|
|
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);
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Order should fail.
|
2022-03-23 06:16:02 +00:00
|
|
|
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);
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Program should not crash.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(order, Is.Invalid(ValidationReason.DestinationMatchesOrigin));
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[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"]
|
2022-03-28 22:05:04 +00:00
|
|
|
.Fleet("London").MovesTo("Yorkshire").GetReference(out var orderLon)
|
2022-03-23 06:16:02 +00:00
|
|
|
.Army("Wales").Supports.Fleet("London").MoveTo("Yorkshire");
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// The move of the army in Yorkshire is illegal. This makes the support of Liverpool also illegal.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderLon, Is.Valid);
|
|
|
|
Assert.That(orderNth, Is.Invalid(ValidationReason.DestinationMatchesOrigin));
|
|
|
|
Assert.That(orderYor, Is.Invalid(ValidationReason.DestinationMatchesOrigin));
|
|
|
|
var orderYorRepl = orderYor.GetReplacementReference<HoldOrder>();
|
2022-03-23 06:16:02 +00:00
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Without the support, the Germans have a stronger force. The army in London dislodges the army in Yorkshire.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.AdjudicateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderLon, Is.Victorious);
|
|
|
|
Assert.That(orderYorRepl, Is.Dislodged);
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[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);
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Order should fail.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(order, Is.Invalid(ValidationReason.InvalidUnitForPower));
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[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);
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Move from London to Belgium should fail.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(order, Is.Invalid(ValidationReason.InvalidOrderTypeForUnit));
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[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"]
|
2022-03-28 16:39:03 +00:00
|
|
|
.Fleet("Trieste").Supports.Fleet("Trieste").Hold().GetReference(out var orderTri);
|
2022-03-23 06:16:02 +00:00
|
|
|
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderTri, Is.Invalid(ValidationReason.NoSelfSupport));
|
|
|
|
var orderTriRepl = orderTri.GetReplacementReference<HoldOrder>();
|
2022-03-28 16:39:03 +00:00
|
|
|
|
|
|
|
// The army in Trieste should be dislodged.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.AdjudicateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderTriRepl, Is.Dislodged);
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void DATC_6_A_9_FleetsMustFollowCoastIfNotOnSea()
|
|
|
|
{
|
|
|
|
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
|
|
|
setup
|
|
|
|
["Italy"]
|
|
|
|
.Fleet("Rome").MovesTo("Venice").GetReference(out var order);
|
|
|
|
|
2022-03-28 22:05:04 +00:00
|
|
|
// Move fails. An army can go from Rome to Venice, but a fleet can not.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(order, Is.Invalid(ValidationReason.UnreachableDestination));
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void DATC_6_A_10_SupportOnUnreachableDestinationNotPossible()
|
|
|
|
{
|
|
|
|
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
|
|
|
setup
|
|
|
|
["Austria"]
|
2022-03-28 16:39:03 +00:00
|
|
|
.Army("Venice").Holds().GetReference(out var orderVen)
|
2022-03-23 06:16:02 +00:00
|
|
|
["Italy"]
|
|
|
|
.Army("Apulia").MovesTo("Venice")
|
2022-03-28 16:39:03 +00:00
|
|
|
.Fleet("Rome").Supports.Army("Apulia").MoveTo("Venice").GetReference(out var orderRom);
|
2022-03-23 06:16:02 +00:00
|
|
|
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-23 06:16:02 +00:00
|
|
|
|
2022-03-28 16:39:03 +00:00
|
|
|
// The support of Rome is illegal, because Venice can not be reached from Rome by a fleet.
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderRom, Is.Invalid(ValidationReason.UnreachableSupport));
|
2022-03-23 06:16:02 +00:00
|
|
|
|
2022-03-28 16:39:03 +00:00
|
|
|
// Venice is not dislodged.
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.AdjudicateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderVen, Is.NotDislodged);
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void DATC_6_A_11_SimpleBounce()
|
|
|
|
{
|
|
|
|
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
|
|
|
setup
|
|
|
|
["Austria"]
|
2022-03-28 16:39:03 +00:00
|
|
|
.Army("Vienna").MovesTo("Tyrolia").GetReference(out var orderVie)
|
2022-03-23 06:16:02 +00:00
|
|
|
["Italy"]
|
2022-03-28 16:39:03 +00:00
|
|
|
.Army("Venice").MovesTo("Tyrolia").GetReference(out var orderVen);
|
|
|
|
|
2024-08-28 21:27:35 +00:00
|
|
|
setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderVie, Is.Valid);
|
|
|
|
Assert.That(orderVen, Is.Valid);
|
2022-03-28 16:39:03 +00:00
|
|
|
|
|
|
|
// The two units bounce.
|
2024-08-28 21:27:35 +00:00
|
|
|
var adjudications = setup.AdjudicateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderVie, Is.Repelled);
|
|
|
|
Assert.That(orderVie, Is.NotDislodged);
|
|
|
|
Assert.That(orderVen, Is.Repelled);
|
|
|
|
Assert.That(orderVen, Is.NotDislodged);
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void DATC_6_A_12_BounceOfThreeUnits()
|
|
|
|
{
|
|
|
|
TestCaseBuilder setup = new TestCaseBuilder(StandardEmpty);
|
|
|
|
setup
|
|
|
|
["Austria"]
|
2022-03-28 16:39:03 +00:00
|
|
|
.Army("Vienna").MovesTo("Tyrolia").GetReference(out var orderVie)
|
2022-03-23 06:16:02 +00:00
|
|
|
["Germany"]
|
2022-03-28 16:39:03 +00:00
|
|
|
.Army("Munich").MovesTo("Tyrolia").GetReference(out var orderMun)
|
2022-03-23 06:16:02 +00:00
|
|
|
["Italy"]
|
2022-03-28 16:39:03 +00:00
|
|
|
.Army("Venice").MovesTo("Tyrolia").GetReference(out var orderVen);
|
|
|
|
|
2024-08-28 21:27:35 +00:00
|
|
|
var validations = setup.ValidateOrders(MovementPhase);
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderVie, Is.Valid);
|
|
|
|
Assert.That(orderMun, Is.Valid);
|
|
|
|
Assert.That(orderVen, Is.Valid);
|
2022-03-28 16:39:03 +00:00
|
|
|
|
2024-08-28 21:27:35 +00:00
|
|
|
var adjudications = setup.AdjudicateOrders(MovementPhase);
|
2022-03-28 16:39:03 +00:00
|
|
|
// The three units bounce.
|
2022-03-28 22:05:04 +00:00
|
|
|
Assert.That(orderVie, Is.Repelled);
|
|
|
|
Assert.That(orderVie, Is.NotDislodged);
|
|
|
|
Assert.That(orderMun, Is.Repelled);
|
|
|
|
Assert.That(orderMun, Is.NotDislodged);
|
|
|
|
Assert.That(orderVen, Is.Repelled);
|
|
|
|
Assert.That(orderVen, Is.NotDislodged);
|
2022-03-23 06:16:02 +00:00
|
|
|
}
|
|
|
|
}
|