Example #1
0
        private void AssertExpectedIdenticalResult(string input1, string input2, bool expected)
        {
            DiffResult result = GetDiffResult(input1, input2);
            string     msg    = "Identical: comparing " + input1 + " to " + input2 + ": " + result.Difference;

            OldAssert.AreEqual(expected, result.Identical, msg);
        }
Example #2
0
        /// <summary>
        /// Asserts that the flattened String obtained by executing an Xpath on some XML is a particular value
        /// </summary>
        /// <param name="anXPathExpression">An X path expression.</param>
        /// <param name="inXml">The XML to test.</param>
        /// <param name="expectedValue">The expected value.</param>
        public static void XPathEvaluatesTo(string anXPathExpression, XmlInput inXml,
                                            string expectedValue)
        {
            XPath xpath = new XPath(anXPathExpression);

            OldAssert.AreEqual(expectedValue, xpath.EvaluateXPath(inXml));
        }
Example #3
0
        [SetUp] public void CreateMinorDifference()
        {
            DifferenceType id = DifferenceType.AttributeSequence;

            OldAssert.AreEqual(false, Differences.IsMajorDifference(id));
            minorDifference = new Difference(id);
        }
Example #4
0
        [Test] public void XpathExistsFalseForUnmatchedExpression()
        {
            XPath xpath = new XPath(NONEXISTENT_XPATH);

            OldAssert.AreEqual(false,
                               xpath.XPathExists(SIMPLE_XML));
        }
Example #5
0
        [Test] public void XpathExistsTrueForXpathThatExists()
        {
            XPath xpath = new XPath(EXISTENT_XPATH);

            OldAssert.AreEqual(true,
                               xpath.XPathExists(SIMPLE_XML));
        }
Example #6
0
        [Test] public void TextReaderInputTranslatesToXmlReader()
        {
            XmlInput input  = new XmlInput(new StringReader(INPUT));
            string   actual = ReadOuterXml(input.CreateXmlReader());

            OldAssert.AreEqual(_expected, actual);
        }
Example #7
0
        public void EqualResultForSameReader()
        {
            TextReader reader = new StringReader("<empty/>");
            DiffResult result = PerformDiff(reader, reader);

            OldAssert.AreEqual(true, result.Equal);
        }
Example #8
0
        [Test] public void XpathEvaluatesMultiNodeExpression()
        {
            string expectedValue = "onetwo";
            XPath  xpath         = new XPath(MULTI_NODE_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(MORE_COMPLEX_XML));
        }
Example #9
0
        [Test] public void XpathEvaluatesCountExpression()
        {
            string expectedValue = "2";
            XPath  xpath         = new XPath(COUNT_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(MORE_COMPLEX_XML));
        }
Example #10
0
        [Test] public void XpathEvaluatesToEmptyStringForUnmatchedExpression()
        {
            string expectedValue = "";
            XPath  xpath         = new XPath(NONEXISTENT_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(SIMPLE_XML));
        }
Example #11
0
        [Test] public void XpathEvaluatesToTextValueForSimpleString()
        {
            string expectedValue = "one two";
            XPath  xpath         = new XPath(EXISTENT_XPATH);

            OldAssert.AreEqual(expectedValue,
                               xpath.EvaluateXPath(SIMPLE_XML));
        }
Example #12
0
        [Test] public void CanPerformTransform()
        {
            Xslt   xslt   = new Xslt(IDENTITY_TRANSFORM);
            string input  = "<qwerty>uiop</qwerty>";
            string output = new string(input.ToCharArray());

            OldAssert.AreEqual(output, xslt.Transform(input).AsString());
            OldAssert.AreEqual(output, xslt.Transform(input).AsString());
        }
Example #13
0
 [Test] public void NotIdenticalButEqualAfterMinorDifferenceFound()
 {
     _result.DifferenceFound(_diff, _minorDifference);
     OldAssert.AreEqual(false, _result.Identical);
     OldAssert.AreEqual(true, _result.Equal);
     OldAssert.AreEqual(_diff.OptionalDescription
                        + Environment.NewLine
                        + _minorDifference.ToString(), _result.StringValue);
 }
Example #14
0
 /// <summary>
 /// Verifies that the property value <see cref="ICollection.Count"/>
 /// of <paramref name="actual"/> is equal to <paramref name="expected"/>.
 /// </summary>
 /// <param name="expected">
 /// Expected value.
 /// </param>
 /// <param name="actual">
 /// Instance containing the tested value.
 /// </param>
 public static void AreCountEqual(
     Int32 expected,
     ICollection actual
     )
 {
     OldAssert.IsNotNull(actual);
     OldAssert.AreEqual(expected, actual.Count,
                        "Property Count not equal");
 }
Example #15
0
 private Validator PerformAssertion(Stream input, bool expected)
 {
     using (input)
     {
         Validator validator = new Validator(new XmlInput(new StreamReader(input)));
         OldAssert.AreEqual(expected, validator.IsValid, validator.ValidationMessage);
         return(validator);
     }
 }
Example #16
0
 /// <summary>
 /// Verifies that the property value <see cref="ICollection.IsSynchronized"/>
 /// of <paramref name="actual"/> is equal to <paramref name="expected"/>.
 /// </summary>
 /// <param name="expected">
 /// Expected value.
 /// </param>
 /// <param name="actual">
 /// Instance containing the tested value.
 /// </param>
 public static void AreIsSynchronizedEqual(
     Boolean expected,
     ICollection actual
     )
 {
     OldAssert.IsNotNull(actual);
     OldAssert.AreEqual(expected, actual.IsSynchronized,
                        "Property IsSynchronized not equal");
 }
        [Test] public void DefaultConfiguredWithGenericDescription()
        {
            DiffConfiguration diffConfiguration = new DiffConfiguration();

            OldAssert.AreEqual(DiffConfiguration.DEFAULT_DESCRIPTION,
                               diffConfiguration.Description);

            OldAssert.AreEqual(DiffConfiguration.DEFAULT_DESCRIPTION,
                               new XmlDiff("", "").OptionalDescription);
        }
Example #18
0
        [Test] public void ToStringContainsId()
        {
            string commentDifference = minorDifference.ToString();
            string idValue           = "type: " + (int)DifferenceType.AttributeSequence;

            OldAssert.AreEqual(
                true,
                commentDifference.IndexOfAny(idValue.ToCharArray()) > 0,
                "contains " + idValue);
        }
Example #19
0
        /// <summary>
        /// Verifies that the <see cref="ICollection.Count"/> property
        /// is synchronized with the number of iterated elements.
        /// </summary>
        /// <param name="col">
        /// Collection to test.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="col"/> is a null reference (Nothing in Visual Basic).
        /// </exception>
        public static void IsCountCorrect(ICollection col)
        {
            if (col == null)
            {
                throw new ArgumentNullException("col");
            }
            int i = 0;

            foreach (Object o in col)
            {
                ++i;
            }
            OldAssert.AreEqual(i, col.Count);
        }
Example #20
0
        /// <summary>
        /// Verifies that the property value <see cref="ICollection.SyncRoot"/>
        /// of <paramref name="actual"/> is equal to <paramref name="expected"/>.
        /// </summary>
        /// <param name="expected">
        /// Expected value.
        /// </param>
        /// <param name="actual">
        /// Instance containing the tested value.
        /// </param>
        public static void AreSyncRootEqual(
            Object expected,
            ICollection actual
            )
        {
            if (expected == null && actual == null)
            {
                return;
            }

            OldAssert.IsNotNull(expected);
            OldAssert.IsNotNull(actual);
            OldAssert.AreEqual(expected, actual.SyncRoot,
                               "Property SyncRoot not equal");
        }
Example #21
0
        [Test] public void StreamInputTranslatesToXmlReader()
        {
            MemoryStream stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream, Encoding.Default);

            writer.WriteLine(INPUT);
            writer.Flush();
            stream.Seek(0, SeekOrigin.Begin);
            XmlInput input  = new XmlInput(stream);
            string   actual = ReadOuterXml(input.CreateXmlReader());

            try {
                OldAssert.AreEqual(_expected, actual);
            } finally {
                writer.Close();
            }
        }
Example #22
0
        public static void AreEqual(int[] expected, int[] actual)
        {
            if (expected == null && actual == null)
            {
                return;
            }

            OldAssert.IsNotNull(expected);
            OldAssert.IsNotNull(actual);

            OldAssert.AreEqual(expected.Rank, actual.Rank, "Rank are not equal");
            OldAssert.AreEqual(expected.Length, actual.Length);
            for (int i = 0; i < expected.Length; ++i)
            {
                OldAssert.AreEqual(expected[i], actual[i]);
            }
        }
Example #23
0
 /// <summary>
 /// Asserts that some XML is valid.
 /// </summary>
 /// <param name="validator">A <see cref="Validator"/> object containing the XML to validate.</param>
 public static void XmlValid(Validator validator)
 {
     OldAssert.AreEqual(true, validator.IsValid, validator.ValidationMessage);
 }
Example #24
0
        /// <summary>
        /// Asserts that two pieces of XML are identical (or not) given their diff and a boolean value
        /// </summary>
        /// <param name="xmlDiff">The XML diff.</param>
        /// <param name="identical">if set to <c>true</c> the assert passes if the XML is identical.
        /// if <c>false</c>, the assert passes if the XML is not identical.</param>
        private static void XmlIdentical(XmlDiff xmlDiff, bool identical)
        {
            DiffResult diffResult = xmlDiff.Compare();

            OldAssert.AreEqual(identical, diffResult.Identical, xmlDiff.OptionalDescription);
        }
Example #25
0
        /// <summary>
        /// Asserts that two pieces of XML are similar (or not) given their diff and a boolean value
        /// </summary>
        /// <param name="xmlDiff">The XML diff.</param>
        /// <param name="equal">if set to <c>true</c> the assert passes if the XML is similar.
        /// if <c>false</c>, the assert passes if the XML is not similar.</param>
        private static void XmlEquals(XmlDiff xmlDiff, bool equal)
        {
            DiffResult diffResult = xmlDiff.Compare();

            OldAssert.AreEqual(equal, diffResult.Equal, FailMessage(equal, xmlDiff.OptionalDescription));
        }
Example #26
0
        [Test] public void EqualsSelf()
        {
            XmlInput input = new XmlInput(INPUT);

            OldAssert.AreEqual(input, input);
        }
Example #27
0
        [Test] public void NotEqualsADifferentClass()
        {
            XmlInput input = new XmlInput(INPUT);

            OldAssert.AreEqual(false, input.Equals(INPUT));
        }
Example #28
0
 [Test] public void NewDiffResultIsEqualAndIdentical()
 {
     OldAssert.AreEqual(true, _result.Identical);
     OldAssert.AreEqual(true, _result.Equal);
     OldAssert.AreEqual("Identical", _result.StringValue);
 }
Example #29
0
        [Test] public void NotEqualsNull()
        {
            XmlInput input = new XmlInput(INPUT);

            OldAssert.AreEqual(false, input.Equals(null));
        }
Example #30
0
        /// <summary>
        /// Assert that an XPath expression matches at least one node in someXml
        /// </summary>
        /// <param name="anXPathExpression">An X path expression.</param>
        /// <param name="inXml">The XML to test.</param>
        public static void XPathExists(string anXPathExpression, XmlInput inXml)
        {
            XPath xpath = new XPath(anXPathExpression);

            OldAssert.AreEqual(true, xpath.XPathExists(inXml));
        }