Make adjudicator reusable to decrease verbosity
This commit is contained in:
parent
604dda95e8
commit
b679558d9c
|
@ -11,11 +11,11 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Validation_ValidHold()
|
public void Validation_ValidHold()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").Holds().GetReference(out var order);
|
.Army("Mun").Holds().GetReference(out var order);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
|
|
||||||
Assert.That(order, Is.Valid, "Unexpected validation result");
|
Assert.That(order, Is.Valid, "Unexpected validation result");
|
||||||
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
||||||
|
@ -24,11 +24,11 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Validation_ValidMove()
|
public void Validation_ValidMove()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").MovesTo("Tyr").GetReference(out var order);
|
.Army("Mun").MovesTo("Tyr").GetReference(out var order);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
|
|
||||||
Assert.That(order, Is.Valid, "Unexpected validation result");
|
Assert.That(order, Is.Valid, "Unexpected validation result");
|
||||||
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
||||||
|
@ -37,11 +37,11 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Validation_ValidConvoy()
|
public void Validation_ValidConvoy()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Fleet("Nth").Convoys.Army("Hol").To("Lon").GetReference(out var order);
|
.Fleet("Nth").Convoys.Army("Hol").To("Lon").GetReference(out var order);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
|
|
||||||
Assert.That(order, Is.Valid, "Unexpected validation result");
|
Assert.That(order, Is.Valid, "Unexpected validation result");
|
||||||
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
||||||
|
@ -50,11 +50,11 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Validation_ValidSupportHold()
|
public void Validation_ValidSupportHold()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").Supports.Army("Kie").Hold().GetReference(out var order);
|
.Army("Mun").Supports.Army("Kie").Hold().GetReference(out var order);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
|
|
||||||
Assert.That(order, Is.Valid, "Unexpected validation result");
|
Assert.That(order, Is.Valid, "Unexpected validation result");
|
||||||
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
||||||
|
@ -63,11 +63,11 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Validation_ValidSupportMove()
|
public void Validation_ValidSupportMove()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").Supports.Army("Kie").MoveTo("Ber").GetReference(out var order);
|
.Army("Mun").Supports.Army("Kie").MoveTo("Ber").GetReference(out var order);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
|
|
||||||
Assert.That(order, Is.Valid, "Unexpected validation result");
|
Assert.That(order, Is.Valid, "Unexpected validation result");
|
||||||
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
Assert.That(order.Replacement, Is.Null, "Unexpected order replacement");
|
||||||
|
@ -76,11 +76,11 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Adjudication_Hold()
|
public void Adjudication_Hold()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").Holds().GetReference(out var order);
|
.Army("Mun").Holds().GetReference(out var order);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
||||||
|
|
||||||
var adjMun = order.Adjudications;
|
var adjMun = order.Adjudications;
|
||||||
|
@ -96,12 +96,12 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Adjudication_Move()
|
public void Adjudication_Move()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").MovesTo("Tyr").GetReference(out var order);
|
.Army("Mun").MovesTo("Tyr").GetReference(out var order);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
setup.AdjudicateOrders();
|
||||||
|
|
||||||
var adjMun = order.Adjudications;
|
var adjMun = order.Adjudications;
|
||||||
Assert.That(adjMun.All(adj => adj.Resolved), Is.True);
|
Assert.That(adjMun.All(adj => adj.Resolved), Is.True);
|
||||||
|
@ -122,13 +122,13 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Adjudication_Support()
|
public void Adjudication_Support()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new TestCaseBuilder(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").MovesTo("Tyr").GetReference(out var move)
|
.Army("Mun").MovesTo("Tyr").GetReference(out var move)
|
||||||
.Army("Boh").Supports.Army("Mun").MoveTo("Tyr").GetReference(out var support);
|
.Army("Boh").Supports.Army("Mun").MoveTo("Tyr").GetReference(out var support);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
setup.AdjudicateOrders();
|
||||||
|
|
||||||
var adjBoh = support.Adjudications;
|
var adjBoh = support.Adjudications;
|
||||||
Assert.That(adjBoh.All(adj => adj.Resolved), Is.True);
|
Assert.That(adjBoh.All(adj => adj.Resolved), Is.True);
|
||||||
|
@ -156,17 +156,17 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Update_SingleHold()
|
public void Update_SingleHold()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup["Germany"]
|
setup["Germany"]
|
||||||
.Army("Mun").Holds().GetReference(out var mun);
|
.Army("Mun").Holds().GetReference(out var mun);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
Assert.That(mun, Is.Valid);
|
Assert.That(mun, Is.Valid);
|
||||||
|
|
||||||
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
setup.AdjudicateOrders();
|
||||||
Assert.That(mun, Is.NotDislodged);
|
Assert.That(mun, Is.NotDislodged);
|
||||||
|
|
||||||
World updated = setup.UpdateWorld(MovementPhaseAdjudicator.Instance);
|
World updated = setup.UpdateWorld();
|
||||||
|
|
||||||
// Confirm the future was created
|
// Confirm the future was created
|
||||||
Assert.That(updated.Seasons.Count, Is.EqualTo(2));
|
Assert.That(updated.Seasons.Count, Is.EqualTo(2));
|
||||||
|
@ -185,18 +185,18 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Update_DoubleHold()
|
public void Update_DoubleHold()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup[(0, 0)]
|
setup[(0, 0)]
|
||||||
.GetReference(out Season s1)
|
.GetReference(out Season s1)
|
||||||
["Germany"]
|
["Germany"]
|
||||||
.Army("Mun").Holds().GetReference(out var mun1);
|
.Army("Mun").Holds().GetReference(out var mun1);
|
||||||
|
|
||||||
Assert.That(mun1.Order.Unit.Season, Is.EqualTo(s1));
|
Assert.That(mun1.Order.Unit.Season, Is.EqualTo(s1));
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
Assert.That(mun1, Is.Valid);
|
Assert.That(mun1, Is.Valid);
|
||||||
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
setup.AdjudicateOrders();
|
||||||
Assert.That(mun1, Is.NotDislodged);
|
Assert.That(mun1, Is.NotDislodged);
|
||||||
World updated = setup.UpdateWorld(MovementPhaseAdjudicator.Instance);
|
World updated = setup.UpdateWorld();
|
||||||
|
|
||||||
// Confirm the future was created
|
// Confirm the future was created
|
||||||
Season s2 = updated.GetSeason(1, 0);
|
Season s2 = updated.GetSeason(1, 0);
|
||||||
|
@ -217,16 +217,16 @@ public class MovementAdjudicatorTest
|
||||||
.Army("Mun").Holds().GetReference(out var mun2);
|
.Army("Mun").Holds().GetReference(out var mun2);
|
||||||
|
|
||||||
// Validate the second set of orders
|
// Validate the second set of orders
|
||||||
var validations = setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
var validations = setup.ValidateOrders();
|
||||||
Assert.That(validations.Count, Is.EqualTo(1));
|
Assert.That(validations.Count, Is.EqualTo(1));
|
||||||
Assert.That(mun2, Is.Valid);
|
Assert.That(mun2, Is.Valid);
|
||||||
|
|
||||||
// Adjudicate the second set of orders
|
// Adjudicate the second set of orders
|
||||||
var adjudications = setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
var adjudications = setup.AdjudicateOrders();
|
||||||
Assert.That(mun2, Is.NotDislodged);
|
Assert.That(mun2, Is.NotDislodged);
|
||||||
|
|
||||||
// Update the world again
|
// Update the world again
|
||||||
updated = setup.UpdateWorld(MovementPhaseAdjudicator.Instance);
|
updated = setup.UpdateWorld();
|
||||||
Season s3 = updated.GetSeason(s2.Turn + 1, s2.Timeline);
|
Season s3 = updated.GetSeason(s2.Turn + 1, s2.Timeline);
|
||||||
Unit u3 = updated.GetUnitAt("Mun", s3.Coord);
|
Unit u3 = updated.GetUnitAt("Mun", s3.Coord);
|
||||||
Assert.That(u3.Past, Is.EqualTo(mun2.Order.Unit));
|
Assert.That(u3.Past, Is.EqualTo(mun2.Order.Unit));
|
||||||
|
@ -235,18 +235,18 @@ public class MovementAdjudicatorTest
|
||||||
[Test]
|
[Test]
|
||||||
public void Update_DoubleMove()
|
public void Update_DoubleMove()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
setup[(0, 0)]
|
setup[(0, 0)]
|
||||||
.GetReference(out Season s1)
|
.GetReference(out Season s1)
|
||||||
["Germany"]
|
["Germany"]
|
||||||
.Army("Mun").MovesTo("Tyr").GetReference(out var mun1);
|
.Army("Mun").MovesTo("Tyr").GetReference(out var mun1);
|
||||||
|
|
||||||
Assert.That(mun1.Order.Unit.Season, Is.EqualTo(s1));
|
Assert.That(mun1.Order.Unit.Season, Is.EqualTo(s1));
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
Assert.That(mun1, Is.Valid);
|
Assert.That(mun1, Is.Valid);
|
||||||
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
setup.AdjudicateOrders();
|
||||||
Assert.That(mun1, Is.Victorious);
|
Assert.That(mun1, Is.Victorious);
|
||||||
World updated = setup.UpdateWorld(MovementPhaseAdjudicator.Instance);
|
World updated = setup.UpdateWorld();
|
||||||
|
|
||||||
// Confirm the future was created
|
// Confirm the future was created
|
||||||
Season s2 = updated.GetSeason(s1.Turn + 1, s1.Timeline);
|
Season s2 = updated.GetSeason(s1.Turn + 1, s1.Timeline);
|
||||||
|
@ -267,16 +267,16 @@ public class MovementAdjudicatorTest
|
||||||
.Army("Tyr").MovesTo("Mun").GetReference(out var tyr2);
|
.Army("Tyr").MovesTo("Mun").GetReference(out var tyr2);
|
||||||
|
|
||||||
// Validate the second set of orders
|
// Validate the second set of orders
|
||||||
var validations = setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
var validations = setup.ValidateOrders();
|
||||||
Assert.That(validations.Count, Is.EqualTo(1));
|
Assert.That(validations.Count, Is.EqualTo(1));
|
||||||
Assert.That(tyr2, Is.Valid);
|
Assert.That(tyr2, Is.Valid);
|
||||||
|
|
||||||
// Adjudicate the second set of orders
|
// Adjudicate the second set of orders
|
||||||
var adjudications = setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
var adjudications = setup.AdjudicateOrders();
|
||||||
Assert.That(tyr2, Is.Victorious);
|
Assert.That(tyr2, Is.Victorious);
|
||||||
|
|
||||||
// Update the world again
|
// Update the world again
|
||||||
updated = setup.UpdateWorld(MovementPhaseAdjudicator.Instance);
|
updated = setup.UpdateWorld();
|
||||||
Season s3 = updated.GetSeason(s2.Turn + 1, s2.Timeline);
|
Season s3 = updated.GetSeason(s2.Turn + 1, s2.Timeline);
|
||||||
Unit u3 = updated.GetUnitAt("Mun", s3.Coord);
|
Unit u3 = updated.GetUnitAt("Mun", s3.Coord);
|
||||||
Assert.That(u3.Past, Is.EqualTo(u2));
|
Assert.That(u3.Past, Is.EqualTo(u2));
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class TestCaseBuilder
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform validation, adjudication, and update using the defined orders.
|
/// Perform validation, adjudication, and update using the defined orders.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TestCaseBuilder Execute(IPhaseAdjudicator adjudicator);
|
public TestCaseBuilder Execute(IPhaseAdjudicator? adjudicator = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Choose a new season to define orders for.
|
/// Choose a new season to define orders for.
|
||||||
|
@ -199,6 +199,7 @@ public class TestCaseBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
public World World { get; private set; }
|
public World World { get; private set; }
|
||||||
|
private IPhaseAdjudicator LastUsedAdjudicator { get; set; }
|
||||||
public ReadOnlyCollection<Order> Orders { get; }
|
public ReadOnlyCollection<Order> Orders { get; }
|
||||||
private List<Order> OrderList;
|
private List<Order> OrderList;
|
||||||
public List<OrderValidation>? ValidationResults { get; private set; }
|
public List<OrderValidation>? ValidationResults { get; private set; }
|
||||||
|
@ -207,9 +208,10 @@ public class TestCaseBuilder
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a test case builder that will operate on a world.
|
/// Create a test case builder that will operate on a world.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TestCaseBuilder(World world)
|
public TestCaseBuilder(World world, IPhaseAdjudicator? adjudicator = null)
|
||||||
{
|
{
|
||||||
this.World = world;
|
this.World = world;
|
||||||
|
this.LastUsedAdjudicator = adjudicator ?? new TestAdjudicator();
|
||||||
this.OrderList = new();
|
this.OrderList = new();
|
||||||
this.Orders = new(this.OrderList);
|
this.Orders = new(this.OrderList);
|
||||||
this.ValidationResults = null;
|
this.ValidationResults = null;
|
||||||
|
@ -260,20 +262,24 @@ public class TestCaseBuilder
|
||||||
return newUnit;
|
return newUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderValidation> ValidateOrders(IPhaseAdjudicator adjudicator)
|
public List<OrderValidation> ValidateOrders(IPhaseAdjudicator? adjudicator = null)
|
||||||
{
|
{
|
||||||
|
adjudicator ??= this.LastUsedAdjudicator;
|
||||||
|
this.LastUsedAdjudicator = adjudicator;
|
||||||
this.ValidationResults = adjudicator.ValidateOrders(this.World, this.Orders.ToList());
|
this.ValidationResults = adjudicator.ValidateOrders(this.World, this.Orders.ToList());
|
||||||
this.OrderList.Clear();
|
this.OrderList.Clear();
|
||||||
return this.ValidationResults;
|
return this.ValidationResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AdjudicationDecision> AdjudicateOrders(IPhaseAdjudicator adjudicator)
|
public List<AdjudicationDecision> AdjudicateOrders(IPhaseAdjudicator? adjudicator = null)
|
||||||
{
|
{
|
||||||
if (this.ValidationResults == null)
|
if (this.ValidationResults == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Cannot adjudicate before validation");
|
throw new InvalidOperationException("Cannot adjudicate before validation");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adjudicator ??= this.LastUsedAdjudicator;
|
||||||
|
this.LastUsedAdjudicator = adjudicator;
|
||||||
List<Order> orders = this.ValidationResults
|
List<Order> orders = this.ValidationResults
|
||||||
.Where(validation => validation.Valid)
|
.Where(validation => validation.Valid)
|
||||||
.Select(validation => validation.Order)
|
.Select(validation => validation.Order)
|
||||||
|
@ -283,13 +289,15 @@ public class TestCaseBuilder
|
||||||
return this.AdjudicationResults;
|
return this.AdjudicationResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public World UpdateWorld(IPhaseAdjudicator adjudicator)
|
public World UpdateWorld(IPhaseAdjudicator? adjudicator = null)
|
||||||
{
|
{
|
||||||
if (this.AdjudicationResults == null)
|
if (this.AdjudicationResults == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Cannot update before adjudication");
|
throw new InvalidOperationException("Cannot update before adjudication");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adjudicator ??= this.LastUsedAdjudicator;
|
||||||
|
this.LastUsedAdjudicator = adjudicator;
|
||||||
this.World = adjudicator.UpdateWorld(this.World, this.AdjudicationResults);
|
this.World = adjudicator.UpdateWorld(this.World, this.AdjudicationResults);
|
||||||
this.AdjudicationResults = null;
|
this.AdjudicationResults = null;
|
||||||
return this.World;
|
return this.World;
|
||||||
|
@ -584,8 +592,10 @@ public class TestCaseBuilder
|
||||||
this.Order = order;
|
this.Order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestCaseBuilder Execute(IPhaseAdjudicator adjudicator)
|
public TestCaseBuilder Execute(IPhaseAdjudicator? adjudicator = null)
|
||||||
{
|
{
|
||||||
|
adjudicator ??= this.Builder.LastUsedAdjudicator;
|
||||||
|
this.Builder.LastUsedAdjudicator = adjudicator;
|
||||||
this.Builder.ValidateOrders(adjudicator);
|
this.Builder.ValidateOrders(adjudicator);
|
||||||
this.Builder.AdjudicateOrders(adjudicator);
|
this.Builder.AdjudicateOrders(adjudicator);
|
||||||
this.Builder.UpdateWorld(adjudicator);
|
this.Builder.UpdateWorld(adjudicator);
|
||||||
|
|
|
@ -9,27 +9,27 @@ namespace MultiversalDiplomacyTests;
|
||||||
public class TimeTravelTest
|
public class TimeTravelTest
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void MoveIntoOwnPast()
|
public void MoveIntoOwnPastForksTimeline()
|
||||||
{
|
{
|
||||||
TestCaseBuilder setup = new(World.WithStandardMap());
|
TestCaseBuilder setup = new(World.WithStandardMap(), MovementPhaseAdjudicator.Instance);
|
||||||
|
|
||||||
// Hold to move into the future, then move back into the past.
|
// Hold to move into the future, then move back into the past.
|
||||||
setup[(0, 0)]
|
setup[(0, 0)]
|
||||||
.GetReference(out Season s0)
|
.GetReference(out Season s0)
|
||||||
["Germany"]
|
["Germany"]
|
||||||
.Army("Mun").Holds().GetReference(out var mun0)
|
.Army("Mun").Holds().GetReference(out var mun0)
|
||||||
.Execute(MovementPhaseAdjudicator.Instance)
|
.Execute()
|
||||||
[(1, 0)]
|
[(1, 0)]
|
||||||
.GetReference(out Season s1)
|
.GetReference(out Season s1)
|
||||||
["Germany"]
|
["Germany"]
|
||||||
.Army("Mun").MovesTo("Tyr", season: s0).GetReference(out var mun1);
|
.Army("Mun").MovesTo("Tyr", season: s0).GetReference(out var mun1);
|
||||||
|
|
||||||
setup.ValidateOrders(MovementPhaseAdjudicator.Instance);
|
setup.ValidateOrders();
|
||||||
Assert.That(mun1, Is.Valid);
|
Assert.That(mun1, Is.Valid);
|
||||||
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
|
setup.AdjudicateOrders();
|
||||||
Assert.That(mun1, Is.Victorious);
|
Assert.That(mun1, Is.Victorious);
|
||||||
|
|
||||||
World world = setup.UpdateWorld(MovementPhaseAdjudicator.Instance);
|
World world = setup.UpdateWorld();
|
||||||
|
|
||||||
// Confirm that there are now three seasons: the root, a future off the root, and a fork.
|
// Confirm that there are now three seasons: the root, a future off the root, and a fork.
|
||||||
Assert.That(world.Seasons.Count, Is.EqualTo(3));
|
Assert.That(world.Seasons.Count, Is.EqualTo(3));
|
||||||
|
|
Loading…
Reference in New Issue