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


C# XmlDocument.Should方法代码示例

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


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

示例1: When_asserting_an_xml_node_is_the_same_as_the_same_xml_node_it_should_succeed

        public void When_asserting_an_xml_node_is_the_same_as_the_same_xml_node_it_should_succeed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var doc = new XmlDocument();

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                doc.Should().BeSameAs(doc);

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

示例2: XmlDocument

        public void When_asserting_an_xml_node_is_same_as_a_different_xml_node_it_should_fail_with_descriptive_message_and_truncate_xml()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var doc = new XmlDocument();
            doc.LoadXml("<doc>Some very long text that should be truncated.</doc>");
            var otherNode = new XmlDocument();
            otherNode.LoadXml("<otherDoc/>");

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

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>()
                .WithMessage("Expected Xml Node to refer to <otherDoc /> because we want to test the failure message, but found <doc>Some very long....");
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:22,代码来源:XmlNodeAssertionSpecs.cs

示例3: When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail_with_descriptive_message

        public void When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail_with_descriptive_message()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml("<xml/>");

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

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

示例4: When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_with_same_contents_it_should_succeed

        public void When_asserting_an_xml_node_is_equivalent_to_a_different_xml_node_with_same_contents_it_should_succeed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var xml = "<root><a xmlns=\"urn:a\"><data>data</data></a><ns:b xmlns:ns=\"urn:b\"><data>data</data></ns:b></root>";

            var subject = new XmlDocument();
            subject.LoadXml(xml);
            var expected = new XmlDocument();
            expected.LoadXml(xml);

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                subject.Should().BeEquivalentTo(expected);

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

示例5: When_asserting_an_xml_node_is_not_equivalent_to_same_xml_node_it_should_fail_with_descriptive_message

        public void When_asserting_an_xml_node_is_not_equivalent_to_same_xml_node_it_should_fail_with_descriptive_message()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var subject = new XmlDocument();
            subject.LoadXml("<xml>a</xml>");

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

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().
                WithMessage("Did not expect Xml to be equivalent because we want to test the failure message, but it is.");
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:20,代码来源:XmlNodeAssertionSpecs.cs

示例6: When_asserting_an_xml_node_is_not_equivalent_to_som_other_xml_node_it_should_succeed

        public void When_asserting_an_xml_node_is_not_equivalent_to_som_other_xml_node_it_should_succeed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var subject = new XmlDocument();
            subject.LoadXml("<xml>a</xml>");
            var unexpected = new XmlDocument();
            unexpected.LoadXml("<xml>b</xml>");

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                subject.Should().NotBeEquivalentTo(unexpected);

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

示例7: When_asserting_a_non_null_xml_node_is_not_null_it_should_succeed

        public void When_asserting_a_non_null_xml_node_is_not_null_it_should_succeed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml("<xml/>");

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

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

示例8: When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail

        public void When_asserting_an_xml_node_is_null_but_it_is_not_it_should_fail()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml("<xml/>");

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action act = () =>
                xmlDoc.Should().BeNull();

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


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