当前位置: 首页>>代码示例>>C#>>正文


C# XElement.Should方法代码示例

本文整理汇总了C#中System.Xml.Linq.XElement.Should方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.Should方法的具体用法?C# XElement.Should怎么用?C# XElement.Should使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.Should方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IdenticalReplacementIsNotChange

        public void IdenticalReplacementIsNotChange()
        {
            var container = new XElement("C",
                new XElement("b", new XAttribute("SomeProp", DateTime.Today), "Hi there!", new XElement("Deep", "Content")),
                new XElement("c"),
                new XElement("d")
            );

            MergeElements(container,
                new XElement("b", new XAttribute("SomeProp", DateTime.Today), "Hi there!", new XElement("Deep", "Content"))
            ).Should().BeFalse();

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("b", new XAttribute("SomeProp", DateTime.Today), "Hi there!", new XElement("Deep", "Content")),
                new XElement("c"),
                new XElement("d")
            ));
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:18,代码来源:XmlMergerTests.cs

示例2: When_asserting_an_xml_element_is_not_equal_to_a_different_xml_element_it_should_succeed

        public void When_asserting_an_xml_element_is_not_equal_to_a_different_xml_element_it_should_succeed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var element = new XElement("element");
            var otherElement = new XElement("other");

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                element.Should().NotBe(otherElement);

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:19,代码来源:XElementAssertionSpecs.cs

示例3: ElementsAreCaseSensitive

        public void ElementsAreCaseSensitive()
        {
            var container = new XElement("C",
                new XElement("A"),
                new XElement("b")
            );

            MergeElements(container,
                new XElement("a"),
                new XElement("B")
            ).Should().BeTrue();

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("A"),
                new XElement("B"),
                new XElement("a"),
                new XElement("b")
            ));
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:19,代码来源:XmlMergerTests.cs

示例4: When_asserting_an_xml_element_is_equal_to_the_same_xml_element_it_should_succeed

        public void When_asserting_an_xml_element_is_equal_to_the_same_xml_element_it_should_succeed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var element = new XElement("element");
            var sameElement = new XElement("element");

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                element.Should().Be(sameElement);

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:19,代码来源:XElementAssertionSpecs.cs

示例5: XElement

        public void When_asserting_an_xml_element_is_equal_to_a_different_xml_element_it_should_fail_with_descriptive_message()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var element = new XElement("element");
            var otherElement = new XElement("other");

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                element.Should().Be(otherElement, "because we want to test the failure {0}", "message");

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>()
                .WithMessage("Expected XML element to be*other*because we want to test the failure message, but found *element*");
        }
开发者ID:9swampy,项目名称:fluentassertions,代码行数:20,代码来源:XElementAssertionSpecs.cs

示例6: DontStopReorderingAfterLastInsertion

        public void DontStopReorderingAfterLastInsertion()
        {
            var container = new XElement("C",
                new XElement("a"),
                new XElement("c"),
                new XElement("e"),
                new XElement("d")
            );

            MergeElements(container,
                new XElement("c", new XElement("child", "Hi there!")),
                new XElement("b")
            ).Should().BeTrue();

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("a"),
                new XElement("b"),
                new XElement("c", new XElement("child", "Hi there!")),
                new XElement("d"),
                new XElement("e")
            ), "the merger should not stop checking for ordering after it finishes merging all new elements");
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:22,代码来源:XmlMergerTests.cs

示例7: When_asserting_an_xml_element_is_equal_to_an_xml_element_with_a_deep_difference_it_should_fail

        public void When_asserting_an_xml_element_is_equal_to_an_xml_element_with_a_deep_difference_it_should_fail()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var expected =
                new XElement("parent"
                    , new XElement("child"
                        , new XElement("grandChild")));
            var actual =
                new XElement("parent"
                    , new XElement("child"
                        , new XElement("grandChild2")));

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () => actual.Should().Be(expected);

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>();
        }
开发者ID:9swampy,项目名称:fluentassertions,代码行数:24,代码来源:XElementAssertionSpecs.cs

示例8: When_asserting_an_xml_element_is_not_equal_to_the_same_xml_element_it_should_fail

        public void When_asserting_an_xml_element_is_not_equal_to_the_same_xml_element_it_should_fail()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var element = new XElement("element");
            var sameElement = element;

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                element.Should().NotBe(sameElement);

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>();
        }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:19,代码来源:XElementAssertionSpecs.cs

示例9: ReorderExistingElements

        public void ReorderExistingElements()
        {
            var container = new XElement("C",
                new XElement("c"),
                new XElement("d"),
                new XElement("b")
            );

            MergeElements(container,
                new XElement("a"),
                new XElement("e")
            ).Should().BeTrue();

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("a"),
                new XElement("b"),
                new XElement("c"),
                new XElement("d"),
                new XElement("e")
            ));
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:21,代码来源:XmlMergerTests.cs

示例10: ReorderCountsAsChange

        public void ReorderCountsAsChange()
        {
            var container = new XElement("C",
                new XElement("c"),
                new XElement("d"),
                new XElement("b")
            );

            MergeElements(container,
                new XElement("b")
            ).Should().BeTrue();

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("b"),
                new XElement("c"),
                new XElement("d")
            ));
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:18,代码来源:XmlMergerTests.cs

示例11: PopulateEmptyElement

        public void PopulateEmptyElement()
        {
            var container = new XElement("C");

            MergeElements(container,
                new XElement("c"),
                new XElement("a"),
                new XElement("b")
            ).Should().BeTrue();

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("a"),
                new XElement("b"),
                new XElement("c")
            ));
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:16,代码来源:XmlMergerTests.cs

示例12: OverwriteExistingOutOfOrderElement

        public void OverwriteExistingOutOfOrderElement()
        {
            var container = new XElement("C",
                new XElement("c"),
                new XElement("b"),
                new XElement("a")
            );

            MergeElements(container,
                new XElement("a", 42)
            );

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("a", 42),
                new XElement("b"),
                new XElement("c")
            ));
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:18,代码来源:XmlMergerTests.cs

示例13: OverwriteExistingElements

        public void OverwriteExistingElements()
        {
            var container = new XElement("C",
                new XElement("a"),
                new XElement("b"),
                new XElement("c")
            );

            MergeElements(container,
                new XElement("a", 42),
                new XElement("c", new XAttribute("Value", 67))
            ).Should().BeTrue();

            container.Should().BeEquivalentTo(new XElement("C",
                new XElement("a", 42),
                new XElement("b"),
                new XElement("c", new XAttribute("Value", 67))
            ));
        }
开发者ID:sharwell,项目名称:Rebracer,代码行数:19,代码来源:XmlMergerTests.cs

示例14: When_asserting_a_non_null_xml_element_is_not_null_it_should_succeed

        public void When_asserting_a_non_null_xml_element_is_not_null_it_should_succeed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var element = new XElement("element");

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                element.Should().NotBeNull();

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:18,代码来源:XElementAssertionSpecs.cs

示例15: When_asserting_an_xml_element_is_null_but_it_is_not_it_should_fail_with_descriptive_message

        public void When_asserting_an_xml_element_is_null_but_it_is_not_it_should_fail_with_descriptive_message()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var element = new XElement("element");

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                element.Should().BeNull("because we want to test the failure {0}", "message");

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>()
                .WithMessage("Expected XML element to be <null> because we want to test the failure message," +
                    " but found <element />.");
        }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:20,代码来源:XElementAssertionSpecs.cs


注:本文中的System.Xml.Linq.XElement.Should方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。