Ejemplo n.º 1
0
        public void ContainerFieldValueCanBeAdded()
        {
            var history = new History();

            history.AddFieldValue(             // new field is created
                "buildings",
                new List <string>(),
                new Date(1, 1, 1),
                "buildings"
                );
            history.AddFieldValue(              // existing field is updated
                "buildings",
                new List <string> {
                "aqueduct", "temple"
            },
                new Date(867, 1, 1),
                "buildings"
                );
            Assert.Collection(history.Fields,
                              item1 => Assert.Equal("buildings", item1.Key)
                              );
            Assert.Collection(history.Fields["buildings"].ValueHistory,
                              item1 => {
                Assert.Equal(new Date(1, 1, 1), item1.Key);
                Assert.Equal(new List <string>(), item1.Value);
            },
                              item2 => {
                Assert.Equal(new Date(867, 1, 1), item2.Key);
                Assert.Equal(new List <string> {
                    "aqueduct", "temple"
                }, item2.Value);
            }
                              );
        }
Ejemplo n.º 2
0
        public void SimpleFieldValueCanBeAdded()
        {
            var history = new History();

            history.AddFieldValue("holder", "0", new Date(1, 1, 1), "holder");             // new field is created
            history.AddFieldValue("holder", "69", new Date(867, 1, 1), "holder");          // existing field is updated
            Assert.Collection(history.Fields,
                              item1 => Assert.Equal("holder", item1.Key)
                              );
            Assert.Collection(history.Fields["holder"].ValueHistory,
                              item1 => {
                Assert.Equal(new Date(1, 1, 1), item1.Key);
                Assert.Equal("0", item1.Value);
            },
                              item2 => {
                Assert.Equal(new Date(867, 1, 1), item2.Key);
                Assert.Equal("69", item2.Value);
            }
                              );
        }
Ejemplo n.º 3
0
    public void TitlesAreOutputted()
    {
        const string outputModName = "outputMod";

        var titles  = new Title.LandedTitles();
        var kingdom = titles.Add("k_kingdom");
        var history = new History();

        history.AddFieldValue("liege", 0, new Date(20, 1, 1), "liege");
        var kingdomHistory = new TitleHistory(history);

        kingdom.AddHistory(kingdomHistory);

        var duchy = titles.Add("d_duchy");

        duchy.DeJureLiege = kingdom;

        var county = titles.Add("c_county");

        county.DeJureLiege = duchy;

        var barony = titles.Add("b_barony");

        barony.DeJureLiege = county;

        var specialTitle   = titles.Add("k_special_title");
        var specialHistory = new History();

        specialHistory.AddFieldValue("holder", "bob_42", new Date(20, 1, 1), "holder");
        var specialTitleHistory = new TitleHistory(specialHistory);

        specialTitle.AddHistory(specialTitleHistory);

        var titleHistoryPath       = Path.Combine("output", outputModName, "history", "titles");
        var kingdomHistoryPath     = Path.Combine(titleHistoryPath, "k_kingdom.txt");
        var otherTitlesHistoryPath = Path.Combine(titleHistoryPath, "00_other_titles.txt");

        SystemUtils.TryCreateFolder(titleHistoryPath);

        var landedTitlesPath = Path.Combine("output", outputModName, "common", "landed_titles", "00_landed_titles.txt");

        SystemUtils.TryCreateFolder(CommonFunctions.GetPath(landedTitlesPath));

        TitlesOutputter.OutputTitles(outputModName, titles, IMPERATOR_DE_JURE.NO);

        Assert.True(File.Exists(kingdomHistoryPath));
        using var kingdomHistoryFile = File.OpenRead(kingdomHistoryPath);
        var reader = new StreamReader(kingdomHistoryFile);

        Assert.Equal("k_kingdom={", reader.ReadLine());
        Assert.Equal("\t20.1.1={", reader.ReadLine());
        Assert.Equal("\t\tliege=0", reader.ReadLine());
        Assert.Equal("\t}", reader.ReadLine());
        Assert.Equal("}", reader.ReadLine());
        Assert.True(reader.EndOfStream);

        Assert.True(File.Exists(otherTitlesHistoryPath));
        using var otherTitlesHistoryFile = File.OpenRead(otherTitlesHistoryPath);
        reader = new StreamReader(otherTitlesHistoryFile);
        Assert.Equal("k_special_title={", reader.ReadLine());
        Assert.Equal("\t20.1.1={", reader.ReadLine());
        Assert.Equal("\t\tholder=\"bob_42\"", reader.ReadLine());
        Assert.Equal("\t}", reader.ReadLine());
        Assert.Equal("}", reader.ReadLine());
        Assert.True(reader.EndOfStream);

        Assert.True(File.Exists(landedTitlesPath));
        using var landedTitlesFile = File.OpenRead(landedTitlesPath);
        reader = new StreamReader(landedTitlesFile);
        Assert.Equal("k_kingdom={", reader.ReadLine());
        Assert.Equal("\td_duchy={", reader.ReadLine());
        Assert.Equal("\t\tc_county={", reader.ReadLine());
        Assert.Equal("\t\t\tb_barony={", reader.ReadLine());
        Assert.Equal("\t\t\t\tlandless=no", reader.ReadLine());
        Assert.Equal("\t\t\t\tdefinite_form=no", reader.ReadLine());
        Assert.Equal("\t\t\t\truler_uses_title_name=no", reader.ReadLine());
        Assert.Equal("\t\t\t}", reader.ReadLine());
        Assert.Equal("\t\t\tlandless=no", reader.ReadLine());
        Assert.Equal("\t\t\tdefinite_form=no", reader.ReadLine());
        Assert.Equal("\t\t\truler_uses_title_name=no", reader.ReadLine());
        Assert.Equal("\t\t}", reader.ReadLine());
        Assert.Equal("\t\tlandless=no", reader.ReadLine());
        Assert.Equal("\t\tdefinite_form=no", reader.ReadLine());
        Assert.Equal("\t\truler_uses_title_name=no", reader.ReadLine());
        Assert.Equal("\t}", reader.ReadLine());
        Assert.Equal("\tlandless=no", reader.ReadLine());
        Assert.Equal("\tdefinite_form=no", reader.ReadLine());
        Assert.Equal("\truler_uses_title_name=no", reader.ReadLine());
        Assert.Equal("}", reader.ReadLine());
        Assert.Equal("k_special_title={", reader.ReadLine());
        Assert.Equal("\tlandless=no", reader.ReadLine());
        Assert.Equal("\tdefinite_form=no", reader.ReadLine());
        Assert.Equal("\truler_uses_title_name=no", reader.ReadLine());
        Assert.Equal("}", reader.ReadLine());
        Assert.True(reader.EndOfStream);
    }