示例#1
0
        public void ProcessInheritance_MultilayerInheritanceTest()
        {
            var defaults = CreateTestNode(@"<defaults><dep1 type=""Foo, Foo"" /></defaults>");
            var abs      = CreateTestNode(@"<config name=""Foo"" abstract=""true""><dep2 type=""Bar, Bar"" /></config>");
            var target   = CreateTestNode(@"<config name=""Bar""><dep3 type=""Baz, Baz"" /></config>");

            var sut = new XmlInheritanceEngine();

            var result = sut.ProcessInheritance(sut.ProcessInheritance(defaults, abs), target);


            result.OuterXml.Should().Be(@"<config name=""Bar""><dep1 type=""Foo, Foo"" /><dep2 type=""Bar, Bar"" /><dep3 type=""Baz, Baz"" /></config>");
        }
示例#2
0
        public void ProcessInheritance_ShouldRemoveSourceChildren_WhenTypeIsPatched()
        {
            var source = CreateTestNode(@"<config><element type=""foo"" baz=""baz""><cfg /></element></config>");
            var target = CreateTestNode(@"<config><element type=""bars"" /></config>");

            var sut = new XmlInheritanceEngine();

            var result = sut.ProcessInheritance(source, target);

            result.OuterXml.Should().Be(@"<config><element type=""bars""></element></config>");
        }
示例#3
0
        public void ProcessInheritance_ShouldOverrideAttributeWhenPatched()
        {
            var source = CreateTestNode(@"<config><element type=""foo"" /></config>");
            var target = CreateTestNode(@"<config><element type=""bars"" /></config>");

            var sut = new XmlInheritanceEngine();

            var result = sut.ProcessInheritance(source, target);

            result.OuterXml.Should().Be(@"<config><element type=""bars"" /></config>");
        }
示例#4
0
        public void ProcessInheritance_ShouldPassChildElement()
        {
            var source = CreateTestNode("<config />");
            var target = CreateTestNode(@"<config><element type=""foo"" /></config>");

            var sut = new XmlInheritanceEngine();

            var result = sut.ProcessInheritance(source, target);

            result.OuterXml.Should().Be(@"<config><element type=""foo"" /></config>");
        }
示例#5
0
        public void ProcessInheritance_ShouldPreserveRootAttributeOnTarget_WhenRootTagNamesAreDifferent()
        {
            var source = CreateTestNode(@"<defaults><element></element></defaults>");
            var target = CreateTestNode(@"<config name=""Foo""><element></element></config>");

            var sut = new XmlInheritanceEngine();

            var result = sut.ProcessInheritance(source, target);

            result.OuterXml.Should().Be(@"<config name=""Foo""><element></element></config>");
        }
示例#6
0
        public void ProcessInheritance_IsOkayWithComments()
        {
            var source = CreateTestNode(@"<config><!-- haha --><element type=""foo"" /><!-- lul --></config>");
            var target = CreateTestNode(@"<config><!-- kek --><element type=""foo"" /><!-- lawl --></config>");

            var sut = new XmlInheritanceEngine();

            var result = sut.ProcessInheritance(source, target);

            result.OuterXml.Should().Be(@"<config><!-- haha --><element type=""foo"" /><!-- lul --></config>");
        }
示例#7
0
        public void ProcessInheritance_ShouldAppendSourceChild_WhenInTypeParameters()
        {
            var source = CreateTestNode(@"<config><element type=""foo""><cfg /></element></config>");
            var target = CreateTestNode(@"<config><element><cfg /></element></config>");

            var sut = new XmlInheritanceEngine();

            var result = sut.ProcessInheritance(source, target);

            // note that no checking of type params is done - it's a pure append if overridden, unless the parent changes the type attribute.
            result.OuterXml.Should().Be(@"<config><element type=""foo""><cfg /><cfg /></element></config>");
        }