71 lines
3.8 KiB
C#
71 lines
3.8 KiB
C#
using MultiversalDiplomacy.Model;
|
|
|
|
using NUnit.Framework;
|
|
|
|
namespace MultiversalDiplomacyTests;
|
|
|
|
public class SeasonTests
|
|
{
|
|
[Test]
|
|
public void TimelineForking()
|
|
{
|
|
World world = World
|
|
.WithMap(Map.Test)
|
|
.ContinueSeason("a0")
|
|
.ContinueSeason("a1")
|
|
.ContinueSeason("a2")
|
|
.ForkSeason("a1")
|
|
.ContinueSeason("b2")
|
|
.ForkSeason("a1")
|
|
.ForkSeason("a2");
|
|
|
|
Assert.That(
|
|
world.Seasons.Select(season => season.ToString()),
|
|
Is.EquivalentTo(new List<string> { "a0", "a1", "a2", "a3", "b2", "b3", "c2", "d3" }),
|
|
"Unexpected seasons");
|
|
|
|
Season a0 = world.GetSeason("a0");
|
|
Season a1 = world.GetSeason("a1");
|
|
Season a2 = world.GetSeason("a2");
|
|
Season a3 = world.GetSeason("a3");
|
|
Season b2 = world.GetSeason("b2");
|
|
Season b3 = world.GetSeason("b3");
|
|
Season c2 = world.GetSeason("c2");
|
|
Season d3 = world.GetSeason("d3");
|
|
|
|
Assert.That(a0.Timeline, Is.EqualTo("a"), "Unexpected trunk timeline");
|
|
Assert.That(a1.Timeline, Is.EqualTo("a"), "Unexpected trunk timeline");
|
|
Assert.That(a2.Timeline, Is.EqualTo("a"), "Unexpected trunk timeline");
|
|
Assert.That(a3.Timeline, Is.EqualTo("a"), "Unexpected trunk timeline");
|
|
Assert.That(b2.Timeline, Is.EqualTo("b"), "Unexpected first alt");
|
|
Assert.That(b3.Timeline, Is.EqualTo("b"), "Unexpected first alt");
|
|
Assert.That(c2.Timeline, Is.EqualTo("c"), "Unexpected second alt");
|
|
Assert.That(d3.Timeline, Is.EqualTo("d"), "Unexpected third alt");
|
|
|
|
Assert.That(a0.Turn, Is.EqualTo(Season.FIRST_TURN + 0), "Unexpected first turn number");
|
|
Assert.That(a1.Turn, Is.EqualTo(Season.FIRST_TURN + 1), "Unexpected next turn number");
|
|
Assert.That(a2.Turn, Is.EqualTo(Season.FIRST_TURN + 2), "Unexpected next turn number");
|
|
Assert.That(a3.Turn, Is.EqualTo(Season.FIRST_TURN + 3), "Unexpected next turn number");
|
|
Assert.That(b2.Turn, Is.EqualTo(Season.FIRST_TURN + 2), "Unexpected fork turn number");
|
|
Assert.That(b3.Turn, Is.EqualTo(Season.FIRST_TURN + 3), "Unexpected fork turn number");
|
|
Assert.That(c2.Turn, Is.EqualTo(Season.FIRST_TURN + 2), "Unexpected fork turn number");
|
|
Assert.That(d3.Turn, Is.EqualTo(Season.FIRST_TURN + 3), "Unexpected fork turn number");
|
|
|
|
Assert.That(world.GetTimelineRoot(a0), Is.EqualTo(a0), "Expected timeline root to be reflexive");
|
|
Assert.That(world.GetTimelineRoot(a3), Is.EqualTo(a0), "Expected trunk timeline to have root");
|
|
Assert.That(world.GetTimelineRoot(b2), Is.EqualTo(b2), "Expected alt timeline root to be reflexive");
|
|
Assert.That(world.GetTimelineRoot(b3), Is.EqualTo(b2), "Expected alt timeline to root at first fork");
|
|
Assert.That(world.GetTimelineRoot(c2), Is.EqualTo(c2), "Expected alt timeline root to be reflexive");
|
|
Assert.That(world.GetTimelineRoot(d3), Is.EqualTo(d3), "Expected alt timeline root to be reflexive");
|
|
|
|
Assert.That(world.InAdjacentTimeline(b3, a3), Is.True, "Expected alts to be adjacent to origin");
|
|
Assert.That(world.InAdjacentTimeline(b3, c2), Is.True, "Expected alts with common origin to be adjacent");
|
|
Assert.That(world.InAdjacentTimeline(b3, d3), Is.False, "Expected alts from different origins not to be adjacent");
|
|
|
|
Assert.That(world.GetFutures(a0), Is.EquivalentTo(new List<Season> { a1 }), "Unexpected futures");
|
|
Assert.That(world.GetFutures(a1), Is.EquivalentTo(new List<Season> { a2, b2, c2 }), "Unexpected futures");
|
|
Assert.That(world.GetFutures(a2), Is.EquivalentTo(new List<Season> { a3, d3 }), "Unexpected futures");
|
|
Assert.That(world.GetFutures(b2), Is.EquivalentTo(new List<Season> { b3 }), "Unexpected futures");
|
|
}
|
|
}
|