public void Parse_should_properly_format_shaders()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"");
            sb.AppendLine(@"VertexStruct VS_DEFAULT_TEXT_INPUT");
            sb.AppendLine(@"{");
            sb.AppendLine(@"	float4	vPosition	: POSITION;");
            sb.AppendLine(@"	float2	vTexCoord	: TEXCOORD0;");
            sb.AppendLine(@"	float4	vColor		: COLOR;");
            sb.AppendLine(@"};");
            sb.AppendLine(@"");
            sb.AppendLine(@"VertexStruct VS_DEFAULT_TEXT_OUTPUT");
            sb.AppendLine(@"{");
            sb.AppendLine(@"	float4	vPosition	: PDX_POSITION;");
            sb.AppendLine(@"	float2	vTexCoord	: TEXCOORD0;");
            sb.AppendLine(@"	float4	vColor		: TEXCOORD1;");
            sb.AppendLine(@"};");


            var args = new ParserArgs()
            {
                ContentSHA      = "sha",
                ModDependencies = new List <string> {
                    "1"
                },
                File    = "gfx\\fx\\test.fxh",
                Lines   = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                ModName = "fake"
            };
            var parser = new WholeTextParser(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("gfx\\fx\\test.fxh");
                switch (i)
                {
                case 0:
                    result[i].Code.Trim().Should().Be(string.Join(Environment.NewLine, sb.ToString().ReplaceTabs().Trim().SplitOnNewLine()));
                    result[i].Id.Should().Be("test.fxh");
                    result[i].ValueType.Should().Be(ValueType.WholeTextFile);
                    break;

                default:
                    break;
                }
                result[i].ModName.Should().Be("fake");
                result[i].Type.Should().Be("gfx\\fx\\fxh");
            }
        }
示例#2
0
        public void Parse_component_tags_should_yield_results()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"weapon_type_energy");
            sb.AppendLine(@"weapon_type_kinetic");
            sb.AppendLine(@"weapon_type_explosive");
            sb.AppendLine(@"weapon_type_strike_craft");
            sb.AppendLine(@"weapon_type_point_defense");
            sb.AppendLine(@"weapon_role_anti_armor");
            sb.AppendLine(@"weapon_role_anti_shield");
            sb.AppendLine(@"weapon_role_artillery");
            sb.AppendLine(@"weapon_role_anti_hull");
            sb.AppendLine(@"weapon_role_point_defense");

            var args = new ParserArgs()
            {
                ContentSHA      = "sha",
                ModDependencies = new List <string> {
                    "1"
                },
                File    = "common\\component_tags\\t.txt",
                Lines   = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                ModName = "fake"
            };
            var parser = new WholeTextParser(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\\component_tags\\t.txt");
                switch (i)
                {
                case 0:
                    result[i].Code.Trim().Should().Be(sb.ToString().Trim());
                    result[i].Id.Should().Be("t.txt");
                    result[i].ValueType.Should().Be(ValueType.WholeTextFile);
                    break;

                default:
                    break;
                }
                result[i].ModName.Should().Be("fake");
                result[i].Type.Should().Be("common\\component_tags\\txt");
            }
        }
        public void Parse_should_yield_results()
        {
            DISetup.SetupContainer();

            var sb = new StringBuilder();

            sb.AppendLine(@"on_game_start = {");
            sb.AppendLine(@"    events = {");
            sb.AppendLine(@"        dmm_mod_1_flag.1");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"}");

            var args = new ParserArgs()
            {
                ContentSHA      = "sha",
                ModDependencies = new List <string> {
                    "1"
                },
                File    = "common\\alerts.txt",
                Lines   = sb.ToString().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
                ModName = "fake"
            };
            var parser = new WholeTextParser(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\\alerts.txt");
                switch (i)
                {
                case 0:
                    result[i].Code.Trim().Should().Be(sb.ToString().Trim());
                    result[i].Id.Should().Be("alerts.txt");
                    result[i].ValueType.Should().Be(ValueType.WholeTextFile);
                    break;

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