Skip to content

Commit

Permalink
More tests for the loading of families (#2307)
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Nov 10, 2024
1 parent d9bf14f commit 368cc27
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using commonItems;
using System;
using System.IO;
using Xunit;

namespace ImperatorToCK3.UnitTests.Imperator.Families;

[Collection("Sequential")]
[CollectionDefinition("Sequential", DisableParallelization = true)]
public class FamiliesTests {
public class FamilyCollectionTests {
[Fact]
public void FamiliesDefaultToEmpty() {
var reader = new BufferedReader(
Expand All @@ -32,6 +34,19 @@ public void FamiliesCanBeLoaded() {
item => Assert.Equal((ulong)42, item.Id),
item => Assert.Equal((ulong)43, item.Id));
}

[Fact]
public void FamiliesCanBeLoadedFromBloc() {
var reader = new BufferedReader(
"families = {\n42={}\n43={}\n}"
);
var families = new ImperatorToCK3.Imperator.Families.FamilyCollection();
families.LoadFamiliesFromBloc(reader);

Assert.Collection(families,
item => Assert.Equal((ulong)42, item.Id),
item => Assert.Equal((ulong)43, item.Id));
}

[Fact]
public void LiteralNoneFamiliesAreNotLoaded() {
Expand All @@ -49,4 +64,18 @@ public void LiteralNoneFamiliesAreNotLoaded() {
item => Assert.Equal((ulong)43, item.Id)
);
}

[Fact]
public void FamilyRedefinitionIsLogged() {
var reader = new BufferedReader(
"= {\n42={}\n42={}\n}"
);
var families = new ImperatorToCK3.Imperator.Families.FamilyCollection();

var output = new StringWriter();
Console.SetOut(output);
families.LoadFamilies(reader);

Assert.Contains("Redefinition of family 42.", output.ToString());
}
}

0 comments on commit 368cc27

Please sign in to comment.