Example #1
0
        public void DefaultParserTest()
        {
            using (TCODFileParser parser = new TCODFileParser())
            {
                AddParserTestStructs(parser);
                parser.Run("exampleConfig.txt");

                Assert.IsTrue(parser.GetIntProperty("item_type.cost") == 300);
                Assert.IsTrue(parser.GetFloatProperty("item_type.weight") == 3.5);
                Assert.IsTrue(parser.GetBoolProperty("item_type.deal_damage") == true);

                TCODDice testDice = new TCODDice(3, 6, 1, 2);
                Assert.IsTrue(parser.GetDiceProperty("item_type.damages") == testDice);

                Color color1 = Color.FromRGB(255, 0, 0);
                Color color2 = Color.FromRGB(128, 96, 96);
                Assert.IsTrue(parser.GetColorProperty("item_type.color") == color1);
                Assert.IsTrue(parser.GetColorProperty("item_type.damaged_color") == color2);
                Assert.IsTrue(parser.GetStringProperty("item_type.damage_type") == "slash");

                //parser.getValueList("list");
                //parser.GetFlag("abstract");
                Assert.IsTrue(parser.GetStringProperty("video.mode") == "800x600");
                Assert.IsTrue(parser.GetBoolProperty("video.fullscreen") == false);
                Assert.IsTrue(parser.GetFloatProperty("input.mouse.sensibility") == .5);
            }
        }
Example #2
0
        public void ImplementedParserTest()
        {
            TCODParserCallbackStruct callback = new TCODParserCallbackStruct(new NewStructureCallback(NewStructCallbackTest), new NewFlagCallback(NewFlagCallbackTest),
                                                                             new NewPropertyCallback(NewPropertyCallbackTest), new EndStructureCallback(EndStructCallbackTest),
                                                                             new ErrorCallback(ErrorCallbackTest));

            using (TCODFileParser parser = new TCODFileParser())
            {
                AddParserTestStructs(parser);
                parser.Run("exampleConfig.txt", ref callback);
            }
        }