Create picks a country; climate is rolled from the school seed and stored. Old Slavic saves lift as Russia. Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
namespace HSchool.Content.Tests;
|
|
|
|
public class CountryDefTests
|
|
{
|
|
private readonly CatalogLoader _loader = new();
|
|
|
|
[Fact]
|
|
public void VanillaCore_LoadsRussiaAndClimatePresets()
|
|
{
|
|
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
|
|
var catalog = _loader.Load([CatalogLoader.CorePackId], PackDocuments.FromDirectory(CatalogLoader.CorePackId, root));
|
|
|
|
Assert.True(catalog.Countries.ContainsKey("Russia"));
|
|
Assert.False(catalog.Countries.ContainsKey("Slavic"));
|
|
var russia = catalog.Countries["Russia"];
|
|
Assert.Equal(
|
|
["RussianLanguage", "BelarusianLanguage", "UkrainianLanguage"],
|
|
russia.Names.Spoken);
|
|
Assert.Equal(0.6f, russia.Names.RelatedLanguageChance);
|
|
Assert.Equal(40, russia.Names.RelatedLanguageMax);
|
|
Assert.True(russia.Names.MaleGiven.Count >= 20);
|
|
Assert.Equal(["TemperateContinental", "ContinentalCold"], russia.ClimatePresets);
|
|
Assert.True(catalog.ClimatePresets.ContainsKey("TemperateContinental"));
|
|
Assert.True(catalog.ClimatePresets.ContainsKey("ContinentalCold"));
|
|
Assert.Equal("Россия", catalog.Label("ru", russia));
|
|
Assert.Equal("Russia", catalog.Label("en", russia));
|
|
}
|
|
|
|
[Fact]
|
|
public void CountryWithoutNames_FailsTheCatalog()
|
|
{
|
|
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load(
|
|
[CatalogLoader.CorePackId],
|
|
[
|
|
PackDocuments.Def(
|
|
CatalogLoader.CorePackId,
|
|
"climates",
|
|
"temperate",
|
|
"""{ "defName": "TemperateContinental" }"""),
|
|
PackDocuments.Def(
|
|
CatalogLoader.CorePackId,
|
|
"countries",
|
|
"ghost",
|
|
"""{ "defName": "GhostLand", "climatePresets": ["TemperateContinental"] }"""),
|
|
]));
|
|
|
|
Assert.Contains("GhostLand", ex.Message, StringComparison.Ordinal);
|
|
Assert.Contains("names", ex.Message, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
[Fact]
|
|
public void CountryWithUnknownPreset_FailsTheCatalog()
|
|
{
|
|
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load(
|
|
[CatalogLoader.CorePackId],
|
|
[
|
|
PackDocuments.Def(
|
|
CatalogLoader.CorePackId,
|
|
"climates",
|
|
"temperate",
|
|
"""{ "defName": "TemperateContinental" }"""),
|
|
PackDocuments.Def(
|
|
CatalogLoader.CorePackId,
|
|
"countries",
|
|
"ghost",
|
|
"""
|
|
{
|
|
"defName": "GhostLand",
|
|
"climatePresets": ["NoSuchClimate"],
|
|
"names": {
|
|
"maleGiven": [{ "form": "Иван" }],
|
|
"femaleGiven": [{ "form": "Анна", "declension": "a" }],
|
|
"surnames": [{ "male": "Иванов", "female": "Иванова" }]
|
|
}
|
|
}
|
|
"""),
|
|
]));
|
|
|
|
Assert.Contains("NoSuchClimate", ex.Message, StringComparison.Ordinal);
|
|
}
|
|
}
|