コード例 #1
0
        public void CanParse_should_be_false_then_true()
        {
            var sb = new StringBuilder();

            sb.AppendLine(@"@test = 1");
            sb.AppendLine(@"");
            sb.AppendLine(@"namespace = dmm_mod");
            sb.AppendLine(@"");
            sb.AppendLine(@"country_event = {");
            sb.AppendLine(@"    id = dmm_mod.1");
            sb.AppendLine(@"    hide_window = yes");
            sb.AppendLine(@"    is_triggered_only = yes");
            sb.AppendLine(@"");
            sb.AppendLine(@"    trigger = {");
            sb.AppendLine(@"        has_global_flag = dmm_mod_1");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"");
            sb.AppendLine(@"    after = {");
            sb.AppendLine(@"        remove_global_flag = dmm_mod_1_opened");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"");
            sb.AppendLine(@"    immediate = {");
            sb.AppendLine(@"        country_event = {");
            sb.AppendLine(@"            id = asl_options.1");
            sb.AppendLine(@"        }");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"}");

            var args = new CanParseArgs()
            {
                File  = "common\\gamerules\\test.txt",
                Lines = new List <string> {
                    "test", "test2 = {}"
                }
            };
            var parser = new KeyParser(new CodeParser(new Logger()), null);

            parser.CanParse(args).Should().BeFalse();
            args.File  = "events\\test.txt";
            args.Lines = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            parser.CanParse(args).Should().BeTrue();
        }
コード例 #2
0
        public void CanParse_inline_edge_case_should_not_parse()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"create_envoys = {		create_ship = { name = random graphical_culture = ""ehof_01"" design = ""NAME_Compound_Envoy"" } }");

            var args = new CanParseArgs()
            {
                File  = "common\\gamerules\\test.txt",
                Lines = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
            };
            var parser = new KeyParser(new CodeParser(new Logger()), null);
            var result = parser.CanParse(args);

            result.Should().BeFalse();
        }
コード例 #3
0
        public void CanParse_inline_edge_case_should_parse()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"entity = { name = ""ai_01_blue_sponsored_colonizer_entity"" clone = ""ai_01_blue_colonizer_entity"" }");

            var args = new CanParseArgs()
            {
                File  = "common\\gamerules\\test.txt",
                Lines = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
            };
            var parser = new KeyParser(new CodeParser(new Logger()), null);
            var result = parser.CanParse(args);

            result.Should().BeTrue();
        }