Esempio n. 1
0
        public void TestInitData()
        {
            Root.Init(init);

            ModDataVisit.InitVisitData(Root.inst);

            Visitor.InitVisitMap(typeof(Root));
            Visitor.SetVisitData(Root.inst);

            Assert.AreEqual(1, Visitor.Get("date.day"));
            Assert.AreEqual(1, Visitor.Get("date.month"));
            Assert.AreEqual(1, Visitor.Get("date.year"));

            Assert.AreEqual(456, Visitor.Get("economy.value"));

            Assert.AreEqual(init.common.name, Visitor.Get("taishou.name"));
            Assert.AreEqual(init.common.age, Visitor.Get("taishou.age"));
            Assert.AreEqual(init.common.party, Visitor.Get("taishou.party.type"));

            //foreach (var income in Root.inst.economy.EnumerateInCome())
            //{
            //    switch (income.name)
            //    {
            //        case "STATIC_POP_TAX":
            //            Assert.AreEqual(Root.def.economy.pop_tax_percent, income.percent.Value);
            //            Assert.AreEqual(Pop.all.Sum(x => x.expectTax.Value), income.maxValue.Value);
            //            Assert.AreEqual(income.maxValue.Value * income.percent.Value / 100, income.currValue.Value);
            //            break;
            //        default:
            //            Assert.Fail();
            //            break;

            //    }
            //}

            //foreach (var output in Root.inst.economy.EnumerateOutput())
            //{
            //    switch (output.name)
            //    {
            //        case "STATIC_REPORT_CHAOTING_TAX":
            //            Assert.AreEqual(Root.def.economy.report_tax_percent, output.percent.Value);
            //            Assert.AreEqual(Chaoting.inst.currMonthTax.Value * output.percent.Value / 100, output.currValue.Value);
            //            break;
            //        default:
            //            Assert.Fail();
            //            break;

            //    }
            //}

            foreach (var departName in Root.def.departs.Keys)
            {
                var departDef = Root.def.departs[departName];

                var depart = Depart.GetByColor(departDef.color.r, departDef.color.g, departDef.color.b);
                Assert.AreEqual(departName, depart.name);

                Assert.AreEqual(departDef.pop_init.Where(x => Root.def.pops[x.name].is_collect_tax).Sum(x => x.num), depart.popNum.Value);

                foreach (var init in departDef.pop_init)
                {
                    var pop = depart.pops.Single(x => x.name == init.name);
                    Assert.AreEqual(init.num, pop.num.Value);
                }
            }

            Visitor.Pos pos = null;
            while (Visitor.EnumerateVisit("depart", ref pos))
            {
                Root.def.departs.ContainsKey(Visitor.Get("depart.name") as string);
            }

            Assert.AreEqual((int)(Depart.all.Sum(x => x.popNum.Value) * Root.def.chaoting.reportPopPercent / 100), Chaoting.inst.reportPopNum.Value);
            //Assert.AreEqual(Root.def.chaoting.taxPercent, Chaoting.inst.taxPercent.Value);
            //Assert.AreEqual(Chaoting.inst.reportPopNum.Value * 0.01 * Root.def.chaoting.taxPercent / 100, Chaoting.inst.currMonthTax.Value);
        }