Ejemplo n.º 1
0
        public void CanParse_should_be_false()
        {
            var args = new CanParseArgs()
            {
                File     = "common\\ship_designs\\test.txt",
                GameType = "Stellaris"
            };
            var parser = new OverwrittenParser(new CodeParser(new Logger()), null);

            parser.CanParse(args).Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void CanParse_pop_jobs_should_be_true()
        {
            var args = new CanParseArgs()
            {
                File     = "common\\pop_jobs\\t.txt",
                GameType = "Stellaris"
            };
            var parser = new OverwrittenParser(new CodeParser(new Logger()), null);

            parser.CanParse(args).Should().BeTrue();
        }
Ejemplo n.º 3
0
        public void CanParse_prescripted_countries_should_be_true()
        {
            var args = new CanParseArgs()
            {
                File     = "prescripted_countries\\t.txt",
                GameType = "Stellaris"
            };
            var parser = new OverwrittenParser(new CodeParser(new Logger()), null);

            parser.CanParse(args).Should().BeTrue();
        }
        public void Parse_should_parse_terraform_links()
        {
            DISetup.SetupContainer();
            var sb = new StringBuilder();

            sb.AppendLine(@"terraform_link = {");
            sb.AppendLine(@"	from = ""pc_frozen""");
            sb.AppendLine(@"	to = ""pc_arctic""");
            sb.AppendLine(@"	");
            sb.AppendLine(@"	energy = 30000");
            sb.AppendLine(@"	duration = 7200");
            sb.AppendLine(@"	");
            sb.AppendLine(@"	condition = {");
            sb.AppendLine(@"		has_technology = ""test""");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"}");

            var args = new ParserArgs()
            {
                ContentSHA      = "sha",
                ModDependencies = new List <string> {
                    "1"
                },
                File    = "common\\terraform\\fake.txt",
                Lines   = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                ModName = "fake"
            };
            var parser = new OverwrittenParser(new CodeParser(new Logger()), null);
            var result = parser.Parse(args).ToList();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(1);
            for (int i = 0; i < 1; i++)
            {
                result[i].ContentSHA.Should().Be("sha");
                result[i].Dependencies.First().Should().Be("1");
                result[i].File.Should().Be("common\\terraform\\fake.txt");
                switch (i)
                {
                case 0:
                    result[i].Id.Should().Be("pc_frozen-pc_arctic");
                    result[i].ValueType.Should().Be(ValueType.OverwrittenObject);
                    break;

                default:
                    break;
                }
                result[i].ModName.Should().Be("fake");
                result[i].Type.Should().Be("common\\terraform\\txt");
            }
        }
Ejemplo n.º 5
0
        public void Parse_should_yield_results()
        {
            DISetup.SetupContainer();
            var sb = new StringBuilder();

            sb.AppendLine(@"@test = 1");
            sb.AppendLine(@"");
            sb.AppendLine(@"asl_mode_options_1 = {");
            sb.AppendLine(@"	potential = {");
            sb.AppendLine(@"		NOT = {");
            sb.AppendLine(@"			has_country_flag = asl_modify_3");
            sb.AppendLine(@"			has_country_flag = asl_modify_5");
            sb.AppendLine(@"		}");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"	allow = {");
            sb.AppendLine(@"		always = yes");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"	effect = {");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"}");
            sb.AppendLine(@"");
            sb.AppendLine(@"asl_mode_options_3 = {");
            sb.AppendLine(@"	potential = {");
            sb.AppendLine(@"		has_country_flag = asl_modify_3");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"	allow = {");
            sb.AppendLine(@"		always = yes");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"	effect = {");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"}");
            sb.AppendLine(@"");
            sb.AppendLine(@"asl_mode_options_5 = {");
            sb.AppendLine(@"	potential = {");
            sb.AppendLine(@"		has_country_flag = asl_modify_5");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"	allow = {");
            sb.AppendLine(@"		always = yes");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"	effect = {");
            sb.AppendLine(@"	}");
            sb.AppendLine(@"}");
            sb.AppendLine(@"");
            sb.AppendLine(@"### END TEMPLATE:effects ###");

            var sb2 = new StringBuilder();

            sb2.AppendLine(@"asl_mode_options_1 = {");
            sb2.AppendLine(@"	potential = {");
            sb2.AppendLine(@"		NOT = {");
            sb2.AppendLine(@"			has_country_flag = asl_modify_3");
            sb2.AppendLine(@"			has_country_flag = asl_modify_5");
            sb2.AppendLine(@"		}");
            sb2.AppendLine(@"	}");
            sb2.AppendLine(@"	allow = {");
            sb2.AppendLine(@"		always = yes");
            sb2.AppendLine(@"	}");
            sb2.AppendLine(@"	effect = {");
            sb2.AppendLine(@"	}");
            sb2.AppendLine(@"}");

            var args = new ParserArgs()
            {
                ContentSHA      = "sha",
                ModDependencies = new List <string> {
                    "1"
                },
                File    = "common\\fake\\fake.txt",
                Lines   = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                ModName = "fake"
            };
            var parser = new OverwrittenParser(new CodeParser(new Logger()), null);
            var result = parser.Parse(args).ToList();

            result.Should().NotBeNullOrEmpty();
            result.Count.Should().Be(4);
            for (int i = 0; i < 4; i++)
            {
                result[i].ContentSHA.Should().Be("sha");
                result[i].Dependencies.First().Should().Be("1");
                result[i].File.Should().Be("common\\fake\\fake.txt");
                switch (i)
                {
                case 0:
                    result[i].Code.Trim().Should().Be("@test = 1");
                    result[i].Id.Should().Be("@test");
                    result[i].ValueType.Should().Be(ValueType.Variable);
                    break;

                case 1:
                    result[i].Id.Should().Be("asl_mode_options_1");
                    result[i].Code.Should().Be(sb2.ToString().Trim().ReplaceTabs());
                    result[i].ValueType.Should().Be(ValueType.OverwrittenObject);
                    break;

                case 2:
                    result[i].Id.Should().Be("asl_mode_options_3");
                    result[i].ValueType.Should().Be(ValueType.OverwrittenObject);
                    break;

                case 3:
                    result[i].Id.Should().Be("asl_mode_options_5");
                    result[i].ValueType.Should().Be(ValueType.OverwrittenObject);
                    break;

                default:
                    break;
                }
                result[i].ModName.Should().Be("fake");
                result[i].Type.Should().Be("common\\fake\\txt");
            }
        }