Ejemplo n.º 1
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, that it has the expected value, and that this element or attribute is unique in the entire fragment.
 /// </summary>
 /// <remarks>
 /// <para>
 /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(string, IXmlPathLoose, XmlOptions)"/>.
 /// </para>
 /// <include file='../../../Gallio/docs/XmlPathLooseSyntax.xml' path='doc/remarks/*' />
 /// </remarks>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
 /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
 /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void IsUnique(string actualXml, string searchedPath, XmlOptions options, string expectedValue, string messageFormat, params object[] messageArgs)
 {
     IsUnique(actualXml, XmlPathRoot.Parse(searchedPath), options, expectedValue, messageFormat, messageArgs);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, and that this element or attribute is unique in the entire fragment.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Options not related to the name case of elements and attributes are going to be ignored.
 /// </para>
 /// </remarks>
 /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXmlReader"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void IsUnique(TextReader actualXmlReader, IXmlPathLoose searchedPath, XmlOptions options)
 {
     IsUnique(actualXmlReader, searchedPath, options, null, null, null);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Asserts that two XML fragments have the same content.
 /// </summary>
 /// <param name="expectedXmlReader">A reader to get the expected XML fragment.</param>
 /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
 /// <param name="options">Equality options.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="expectedXmlReader"/>, <paramref name="actualXmlReader"/>, or <paramref name="options"/> is null.</exception>
 public static void AreEqual(TextReader expectedXmlReader, TextReader actualXmlReader, XmlOptions options)
 {
     AreEqual(expectedXmlReader, actualXmlReader, options, null, null);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, that it has the expected value, and that this element or attribute is unique in the entire fragment.
 /// </summary>
 /// <remarks>
 /// <para>
 /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(TextReader, IXmlPathLoose, XmlOptions, string, object[])"/>.
 /// </para>
 /// <include file='../../../Gallio/docs/XmlPathLooseSyntax.xml' path='doc/remarks/*' />
 /// </remarks>
 /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
 /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
 /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXmlReader"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void IsUnique(TextReader actualXmlReader, string searchedPath, XmlOptions options, string expectedValue, string messageFormat, params object[] messageArgs)
 {
     IsUnique(actualXmlReader, searchedPath, options, expectedValue, messageFormat, messageArgs);
 }
Ejemplo n.º 5
0
            /// <summary>
            /// Asserts that the XML fragment contains the searched element or attribute, that it has the expected value, and that this element or attribute is unique in the entire fragment.
            /// </summary>
            /// <remarks>
            /// <para>
            /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(string, IXmlPathLoose, XmlOptions, string, object[])"/>.
            /// </para>
            /// </remarks>
            /// <param name="actualXml">The actual XML fragment.</param>
            /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
            /// <param name="options">Options for the search.</param>
            /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
            /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
            /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
            /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
            /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
            public static void IsUnique(string actualXml, IXmlPathLoose searchedPath, XmlOptions options, string expectedValue, string messageFormat, params object[] messageArgs)
            {
                if (actualXml == null)
                    throw new ArgumentNullException("actualXml");
                if (searchedPath == null)
                    throw new ArgumentNullException("searchedPath");
                if (options == null)
                    throw new ArgumentNullException("options");

                AssertionHelper.Verify(() =>
                {
                    NodeFragment actual;

                    try
                    {
                        actual = Parser.Run(actualXml, options.Value);
                    }
                    catch (XmlException exception)
                    {
                        return new AssertionFailureBuilder("Cannot parse the actual XML fragment.")
                            .SetMessage(messageFormat, messageArgs)
                            .AddException(exception)
                            .ToAssertionFailure();
                    }

                    int count = actual.CountAt(searchedPath, expectedValue, options.Value);

                    if (count == 1)
                        return null;

                    var builder = new AssertionFailureBuilder("Expected the XML fragment to contain only once the searched XML element or attribute, " +
                        (count == 0 ? "but none was found." : "But several were found."))
                        .SetMessage(messageFormat, messageArgs)
                        .AddLabeledValue("Item searched", searchedPath.ToString())
                        .AddRawLabeledValue("Number of items found", count);

                    if (expectedValue != null)
                    {
                        builder.AddLabeledValue("Expected value", expectedValue);
                    }

                    return builder.ToAssertionFailure();
                });
            }
        public void AreEqual_fails(string expectedXml, string actualXml, XmlOptions options, int expectedErrors)
        {
            AssertionFailure[] failures = Capture(() => Assert.Xml.AreEqual(expectedXml, actualXml, options));

            if (expectedErrors > 0)
            {
                Assert.Count(1, failures);
                Assert.Count(expectedErrors, failures[0].InnerFailures);
            }
            else
            {
                Assert.IsEmpty(failures);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Options not related to the name case of elements and attributes are going to be ignored.
 /// </para>
 /// </remarks>
 /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
 /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXmlReader"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void Exists(TextReader actualXmlReader, IXmlPathLoose searchedPath, XmlOptions options, string messageFormat, params object[] messageArgs)
 {
     Exists(actualXmlReader, searchedPath, options, null, messageFormat, messageArgs);
 }
Ejemplo n.º 8
0
            /// <summary>
            /// Asserts that the XML fragment contains the searched element or attribute, that it has the expected value, and that this element or attribute is unique in the entire fragment.
            /// </summary>
            /// <remarks>
            /// <para>
            /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(TextReader, IXmlPathLoose, XmlOptions, string, object[])"/>.
            /// </para>
            /// </remarks>
            /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
            /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
            /// <param name="options">Options for the search.</param>
            /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
            /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
            /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
            /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
            /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXmlReader"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
            public static void IsUnique(TextReader actualXmlReader, IXmlPathLoose searchedPath, XmlOptions options, string expectedValue, string messageFormat, params object[] messageArgs)
            {
                if (actualXmlReader == null)
                    throw new ArgumentNullException("actualXmlReader");

                IsUnique(actualXmlReader.ReadToEnd(), searchedPath, options, expectedValue, messageFormat, messageArgs);
            }
Ejemplo n.º 9
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, and that it has the expected value.
 /// </summary>
 /// <remarks>
 /// <para>
 /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(TextReader, IXmlPathLoose, XmlOptions)"/>.
 /// </para>
 /// <include file='../../../Gallio/docs/XmlPathLooseSyntax.xml' path='doc/remarks/*' />
 /// </remarks>
 /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXmlReader"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void Exists(TextReader actualXmlReader, string searchedPath, XmlOptions options, string expectedValue)
 {
     Exists(actualXmlReader, searchedPath, options, expectedValue, null, null);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Options not related to the name case of elements and attributes are going to be ignored.
 /// </para>
 /// </remarks>
 /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXmlReader"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void Exists(TextReader actualXmlReader, IXmlPathLoose searchedPath, XmlOptions options)
 {
     Exists(actualXmlReader, searchedPath, options, null, null, null);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Options not related to the name case of elements and attributes are going to be ignored.
 /// </para>
 /// <include file='../../../Gallio/docs/XmlPathLooseSyntax.xml' path='doc/remarks/*' />
 /// </remarks>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
 /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void Exists(string actualXml, string searchedPath, XmlOptions options, string messageFormat, params object[] messageArgs)
 {
     Exists(actualXml, searchedPath, options, null, messageFormat, messageFormat);
 }
Ejemplo n.º 12
0
            /// <summary>
            /// Asserts that two XML fragments have the same content.
            /// </summary>
            /// <param name="expectedXml">The expected XML fragment.</param>
            /// <param name="actualXml">The actual XML fragment.</param>
            /// <param name="options">Equality options.</param>
            /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
            /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
            /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
            /// <exception cref="ArgumentNullException">Thrown if <paramref name="expectedXml"/>, <paramref name="actualXml"/>, or <paramref name="options"/> is null.</exception>
            public static void AreEqual(string expectedXml, string actualXml, XmlOptions options, string messageFormat, params object[] messageArgs)
            {
                if (expectedXml == null)
                    throw new ArgumentNullException("expectedXml");
                if (actualXml == null)
                    throw new ArgumentNullException("actualXml");

                AssertionHelper.Verify(() =>
                {
                    NodeFragment actual;
                    NodeFragment expected;

                    try
                    {
                        expected = Parser.Run(expectedXml, options.Value);
                    }
                    catch (XmlException exception)
                    {
                        return new AssertionFailureBuilder("Cannot parse the actual XML fragment.")
                            .SetMessage(messageFormat, messageArgs)
                            .AddException(exception)
                            .ToAssertionFailure();
                    }

                    try
                    {
                        actual = Parser.Run(actualXml, options.Value);
                    }
                    catch (XmlException exception)
                    {
                        return new AssertionFailureBuilder("Cannot parse the expected XML fragment.")
                            .SetMessage(messageFormat, messageArgs)
                            .AddException(exception)
                            .ToAssertionFailure();
                    }

                    DiffSet diffSet = actual.Diff(expected, options.Value);

                    if (diffSet.IsEmpty)
                        return null;

                    string message = String.Format("Expected the XML fragments to be equal but {0} difference{1} found.",
                        diffSet.Count, diffSet.Count > 1 ? "s were" : " was");

                    return new AssertionFailureBuilder(message)
                        .SetMessage(messageFormat, messageArgs)
                        .AddRawLabeledValue("Equality Options", options.Value)
                        .AddInnerFailures(diffSet.ToAssertionFailures(expected, actual))
                        .ToAssertionFailure();
                });
            }
Ejemplo n.º 13
0
 /// <summary>
 /// Asserts that two XML fragments have the same content.
 /// </summary>
 /// <param name="expectedXml">The expected XML fragment.</param>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="options">Equality options.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="expectedXml"/>, <paramref name="actualXml"/>, or <paramref name="options"/> is null.</exception>
 public static void AreEqual(string expectedXml, string actualXml, XmlOptions options)
 {
     AreEqual(expectedXml, actualXml, options, null, null);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, and that this element or attribute is unique in the entire fragment.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Options not related to the name case of elements and attributes are going to be ignored.
 /// </para>
 /// </remarks>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
 /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void IsUnique(string actualXml, IXmlPathLoose searchedPath, XmlOptions options, string messageFormat, params object[] messageArgs)
 {
     IsUnique(actualXml, searchedPath, options, null, messageFormat, messageFormat);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute.
 /// </summary>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 /// <remarks>
 /// <para>
 /// Options not related to the name case of elements and attributes are going to be ignored.
 /// </para>
 /// </remarks>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 public static void Exists(string actualXml, IXmlPathLoose searchedPath, XmlOptions options)
 {
     Exists(actualXml, searchedPath, options, null, null, null);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, that it has the expected value, and that this element or attribute is unique in the entire fragment.
 /// </summary>
 /// <remarks>
 /// <para>
 /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(TextReader, IXmlPathLoose, XmlOptions)"/>.
 /// </para>
 /// </remarks>
 /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXmlReader"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void IsUnique(TextReader actualXmlReader, IXmlPathLoose searchedPath, XmlOptions options, string expectedValue)
 {
     IsUnique(actualXmlReader, searchedPath, options, expectedValue, null, null);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, and that it has the expected value.
 /// </summary>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 /// <remarks>
 /// <para>
 /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(string, IXmlPathLoose, XmlOptions)"/>.
 /// </para>
 /// </remarks>
 public static void Exists(string actualXml, IXmlPathLoose searchedPath, XmlOptions options, string expectedValue)
 {
     Exists(actualXml, searchedPath, options, expectedValue, null, null);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, that it has the expected value, and that this element or attribute is unique in the entire fragment.
 /// </summary>
 /// <remarks>
 /// <para>
 /// If <paramref name="expectedValue"/> is set to <c>null</c>, the assertion behaves like <see cref="Assert.Xml.Exists(string, IXmlPathLoose, XmlOptions)"/>.
 /// </para>
 /// </remarks>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="expectedValue">The expected value of the searched item (element or attribute).</param>
 /// <param name="options">Options for the search.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void IsUnique(string actualXml, IXmlPathLoose searchedPath, string expectedValue, XmlOptions options)
 {
     IsUnique(actualXml, searchedPath, options, expectedValue, null, null);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Asserts that the XML fragment contains the searched element or attribute, and that this element or attribute is unique in the entire fragment.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Options not related to the name case of elements and attributes are going to be ignored.
 /// </para>
 /// <include file='../../../Gallio/docs/XmlPathLooseSyntax.xml' path='doc/remarks/*' />
 /// </remarks>
 /// <param name="actualXml">The actual XML fragment.</param>
 /// <param name="searchedPath">The path of the searched element or attribute in the XML fragment.</param>
 /// <param name="options">Options for the search.</param>
 /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualXml"/>, <paramref name="searchedPath"/>, or <paramref name="options"/> is null.</exception>
 public static void IsUnique(string actualXml, string searchedPath, XmlOptions options)
 {
     IsUnique(actualXml, searchedPath, options, null, null, null);
 }
Ejemplo n.º 20
0
            /// <summary>
            /// Asserts that two XML fragments have the same content.
            /// </summary>
            /// <param name="expectedXmlReader">A reader to get the expected XML fragment.</param>
            /// <param name="actualXmlReader">A reader to get the actual XML fragment.</param>
            /// <param name="options">Equality options.</param>
            /// <param name="messageFormat">The custom assertion message format, or null if none.</param>
            /// <param name="messageArgs">The custom assertion message arguments, or null if none.</param>
            /// <exception cref="AssertionException">Thrown if the verification failed unless the current <see cref="AssertionContext.AssertionFailureBehavior" /> indicates otherwise.</exception>
            /// <exception cref="ArgumentNullException">Thrown if <paramref name="expectedXmlReader"/>, <paramref name="actualXmlReader"/>, or <paramref name="options"/> is null.</exception>
            public static void AreEqual(TextReader expectedXmlReader, TextReader actualXmlReader, XmlOptions options, string messageFormat, params object[] messageArgs)
            {
                if (expectedXmlReader == null)
                    throw new ArgumentNullException("expectedXmlReader");
                if (actualXmlReader == null)
                    throw new ArgumentNullException("actualXmlReader");

                AreEqual(expectedXmlReader.ReadToEnd(), actualXmlReader.ReadToEnd(), options, messageFormat, messageArgs);
            }
Ejemplo n.º 21
0
 public void Assert_Exists(string description, string xml, string path, string expectedValue, XmlOptions options, bool shouldPass)
 {
     AssertionFailure[] failures = Capture(() => Assert.Xml.Exists(xml, path, options, expectedValue, description));
     Assert.AreEqual(shouldPass ? 0 : 1, failures.Length);
 }