當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。