2024-08-12 14:33:17 +00:00
|
|
|
using MultiversalDiplomacy.Model;
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace MultiversalDiplomacyTests.Model;
|
|
|
|
|
|
|
|
public class TimelineFactoryTest
|
|
|
|
{
|
|
|
|
[TestCase(0, "a")]
|
|
|
|
[TestCase(1, "b")]
|
|
|
|
[TestCase(25, "z")]
|
|
|
|
[TestCase(26, "aa")]
|
|
|
|
[TestCase(27, "ab")]
|
|
|
|
[TestCase(51, "az")]
|
|
|
|
[TestCase(52, "ba")]
|
|
|
|
[TestCase(53, "bb")]
|
|
|
|
[TestCase(77, "bz")]
|
|
|
|
[TestCase(78, "ca")]
|
2024-08-15 13:52:08 +00:00
|
|
|
public void RoundTripTimelineKeys(int number, string designation)
|
2024-08-12 14:33:17 +00:00
|
|
|
{
|
|
|
|
Assert.That(TimelineFactory.IntToString(number), Is.EqualTo(designation), "Incorrect string");
|
|
|
|
Assert.That(TimelineFactory.StringToInt(designation), Is.EqualTo(number), "Incorrect number");
|
|
|
|
}
|
|
|
|
|
2024-08-15 15:51:17 +00:00
|
|
|
[TestCase("a0", "a", 0)]
|
|
|
|
[TestCase("a1", "a", 1)]
|
|
|
|
[TestCase("a10", "a", 10)]
|
|
|
|
[TestCase("aa2", "aa", 2)]
|
|
|
|
[TestCase("aa22", "aa", 22)]
|
|
|
|
public void SeasonKeySplit(string key, string timeline, int turn)
|
|
|
|
{
|
|
|
|
Assert.That(TimelineFactory.SplitKey(key), Is.EqualTo((timeline, turn)), "Failed to split key");
|
|
|
|
}
|
|
|
|
|
2024-08-12 14:33:17 +00:00
|
|
|
[Test]
|
|
|
|
public void NoSharedFactoryState()
|
|
|
|
{
|
|
|
|
TimelineFactory one = new();
|
|
|
|
TimelineFactory two = new();
|
|
|
|
|
|
|
|
Assert.That(one.NextTimeline(), Is.EqualTo("a"));
|
|
|
|
Assert.That(one.NextTimeline(), Is.EqualTo("b"));
|
|
|
|
Assert.That(one.NextTimeline(), Is.EqualTo("c"));
|
|
|
|
|
|
|
|
Assert.That(two.NextTimeline(), Is.EqualTo("a"));
|
|
|
|
Assert.That(two.NextTimeline(), Is.EqualTo("b"));
|
|
|
|
}
|
|
|
|
}
|