Example #1
0
        /// <summary>
        /// Asserts that the current <see cref="XDocument"/> is not equivalent to the <paramref name="unexpected"/> document,
        /// using its <see cref="XNode.DeepEquals(XNode, XNode)" /> implementation.
        /// </summary>
        /// <param name="unexpected">The unexpected document</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint <XDocumentAssertions> NotBeEquivalentTo(XDocument unexpected, string because, params object[] becauseArgs)
        {
            var xmlReaderValidator = new XmlReaderValidator(Subject.CreateReader(), unexpected.CreateReader(), because, becauseArgs);

            xmlReaderValidator.Validate(false);

            return(new AndConstraint <XDocumentAssertions>(this));
        }
Example #2
0
        /// <summary>
        /// Asserts that the current <see cref="XElement"/> is not equivalent to
        /// the <paramref name="unexpected"/> element, using a semantic
        /// equivalency comparison.
        /// </summary>
        /// <param name="unexpected">The unexpected element</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        public AndConstraint <XElementAssertions> NotBeEquivalentTo(XElement unexpected, string because, params object[] becauseArgs)
        {
            using (XmlReader subjectReader = Subject.CreateReader())
                using (XmlReader otherReader = unexpected.CreateReader())
                {
                    var xmlReaderValidator = new XmlReaderValidator(subjectReader, otherReader, because, becauseArgs);
                    xmlReaderValidator.Validate(false);
                }

            return(new AndConstraint <XElementAssertions>(this));
        }
Example #3
0
        /// <summary>
        /// Asserts that the current <see cref="XmlNode"/> is not equivalent to
        /// the <paramref name="unexpected"/> node.
        /// </summary>
        /// <param name="unexpected">The unexpected node</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
        /// </param>
        /// <param name="reasonArgs">
        /// Zero or more objects to format using the placeholders in <see cref="because" />.
        /// </param>
        /// <returns></returns>
        public AndConstraint <TAssertions> NotBeEquivalentTo(XmlNode unexpected, string because, params object[] reasonArgs)
        {
            using (XmlNodeReader subjectReader = new XmlNodeReader(Subject))
                using (XmlNodeReader unexpectedReader = new XmlNodeReader(unexpected))
                {
                    var xmlReaderValidator = new XmlReaderValidator(subjectReader, unexpectedReader, because, reasonArgs);
                    xmlReaderValidator.Validate(false);
                }

            return(new AndConstraint <TAssertions>((TAssertions)this));
        }
        /// <summary>
        /// Asserts that the current <see cref="XDocument"/> is equivalent to the <paramref name="expected"/> document,
        /// using its <see cref="XNode.DeepEquals(XNode, XNode)" /> implementation.
        /// </summary>
        /// <param name="expected">The expected document</param>
        /// <param name="because">
        /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
        /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
        /// </param>
        /// <param name="becauseArgs">
        /// Zero or more objects to format using the placeholders in <paramref name="because" />.
        /// </param>
        public AndConstraint <XDocumentAssertions> BeEquivalentTo(XDocument expected, string because = "", params object[] becauseArgs)
        {
            using (XmlReader subjectReader = Subject?.CreateReader())
                using (XmlReader otherReader = expected?.CreateReader())
                {
                    var xmlReaderValidator = new XmlReaderValidator(subjectReader, otherReader, because, becauseArgs);
                    xmlReaderValidator.Validate(shouldBeEquivalent: true);
                }

            return(new AndConstraint <XDocumentAssertions>(this));
        }