ex-col-03-santa/SantaClausInc.Test/PreparationTests.cs
github-classroom[bot] 3768d366ff
Initial commit
2024-12-11 15:23:18 +00:00

57 lines
1.9 KiB
C#

using SantaClausInc.Core;
namespace SantaClausInc.Test;
public sealed class PreparationTests
{
public PreparationTests()
{
RandomProvider.Random = new Random(54321);
}
[Fact]
public void PrepareTours()
{
var list = new GoodAndNaughtyList(SampleData.CreateMinimalSampleChildren(false));
var sleighs = Preparation.PrepareTours(list);
sleighs.Count.Should().Be(2, "one sleigh for each city");
CheckSleigh(sleighs[0], "Linz", [
"#01: Travelling to city Linz",
" #02: Moving to house with ID 1",
" #03: Putting into chimney: Book for Sepp (age 6)",
" #04: Putting into chimney: Model Car for Sepp (age 6)",
"#05: Tour done, returning to Northpole HQ"
], "No pile loaded for naughty child => only 1, not 2");
CheckSleigh(sleighs[1], "Leonding", [
"#01: Travelling to city Leonding",
" #02: Moving to house with ID 2",
" #03: Putting into chimney: Toy Blocks for Lisa (age 12)",
" #04: Putting into chimney: Book for Lisa (age 12)",
" #05: Putting into chimney: Doll for Lisa (age 12)",
" #06: Putting into chimney: Watercolors for Lisa (age 12)",
" #07: Putting into chimney: Model Car for Lisa (age 12)",
"#08: Tour done, returning to Northpole HQ"
]);
}
private static void CheckSleigh(Sleigh? sleigh, string expectedCity,
string[] expectedTourPlan, string pileReason = "")
{
if (sleigh is null)
{
Assert.Fail("Sleigh is null");
}
sleigh.TargetCity.Should().Be(expectedCity);
var tourPlan = sleigh.ExecuteTour();
tourPlan.Count.Should().Be(expectedTourPlan.Length, pileReason);
for (var i = 0; i < tourPlan.Count; i++)
{
tourPlan[i].Should().Be(expectedTourPlan[i]);
}
}
}