public void DefaultConfiguredToUseValidatingParser()
        {
            var diffConfiguration = new DiffConfiguration();
            Assert.Equal(DiffConfiguration.DEFAULT_USE_VALIDATING_PARSER,
                         diffConfiguration.UseValidatingParser);

            bool exception = false;
            using (FileStream controlFileStream = File.Open(ValidatorTests.VALID_FILE,
                                                            FileMode.Open,
                                                            FileAccess.Read))
            using (FileStream testFileStream = File.Open(ValidatorTests.INVALID_FILE,
                                                         FileMode.Open,
                                                         FileAccess.Read))
            {
                try
                {
                    var diff = new XmlDiff(new StreamReader(controlFileStream),
                                           new StreamReader(testFileStream));
                    diff.Compare();
                }
                catch (Exception)
                {
                    // should be an XmlSchemaValidationException in .NET 2.0
                    // and later
                    exception = true;
                }
            }
            Assert.True(exception, "expected validation to fail");
        }
Esempio n. 2
0
 public DiffResultTests()
 {
     _result = new DiffResult();
     _diff = new XmlDiff("<a/>", "<b/>");
     _majorDifference = new Difference(DifferenceType.ELEMENT_TAG_NAME_ID, XmlNodeType.Element,
                                       XmlNodeType.Element);
     _minorDifference = new Difference(DifferenceType.ATTR_SEQUENCE_ID, XmlNodeType.Comment, XmlNodeType.Comment);
 }
Esempio n. 3
0
 private static void AssertXmlEquals(XmlDiff xmlDiff, bool equalOrNot)
 {
     DiffResult diffResult = xmlDiff.Compare();
     if (equalOrNot)
     {
         Assert.True(diffResult.Equal, diffResult.StringValue);
     }
     else
     {
         Assert.False(diffResult.Equal, diffResult.StringValue);
     }
 }
Esempio n. 4
0
 private static void AssertXmlIdentical(XmlDiff xmlDiff, bool identicalOrNot)
 {
     DiffResult diffResult = xmlDiff.Compare();
     if (identicalOrNot)
     {
         Assert.True(diffResult.Identical, xmlDiff.OptionalDescription);
     }
     else
     {
         Assert.False(diffResult.Identical, xmlDiff.OptionalDescription);
     }
 }
Esempio n. 5
0
 public void DifferenceFound(XmlDiff inDiff, Difference difference)
 {
     _identical = false;
     if (difference.MajorDifference)
     {
         _equal = false;
     }
     _difference = difference;
     if (_stringBuilder.Length == 0)
     {
         _stringBuilder.Append(inDiff.OptionalDescription);
     }
     _stringBuilder.Append(Environment.NewLine).Append(difference);
 }
        public void CanConfigureNotToUseValidatingParser()
        {
            var diffConfiguration = new DiffConfiguration(false);
            Assert.Equal(false, diffConfiguration.UseValidatingParser);

            FileStream controlFileStream = File.Open(ValidatorTests.VALID_FILE,
                                                     FileMode.Open, FileAccess.Read);
            FileStream testFileStream = File.Open(ValidatorTests.INVALID_FILE,
                                                  FileMode.Open, FileAccess.Read);
            try
            {
                var diff = new XmlDiff(new XmlInput(controlFileStream),
                                       new XmlInput(testFileStream),
                                       diffConfiguration);
                diff.Compare();
            }
            finally
            {
                controlFileStream.Close();
                testFileStream.Close();
            }
        }
Esempio n. 7
0
 public static void AssertXmlNotIdentical(XmlDiff xmlDiff)
 {
     AssertXmlIdentical(xmlDiff, false);
 }
Esempio n. 8
0
 public static void AssertXmlIdentical(XmlDiff xmlDiff)
 {
     AssertXmlIdentical(xmlDiff, true);
 }
Esempio n. 9
0
 public static void AssertXmlNotEquals(XmlDiff xmlDiff)
 {
     AssertXmlEquals(xmlDiff, false);
 }
Esempio n. 10
0
 public static void AssertXmlEquals(XmlDiff xmlDiff)
 {
     AssertXmlEquals(xmlDiff, true);
 }
 public static void ShouldNotBeXmlIdenticalTo(this string actual, string expected)
 {
     var diff = new XmlDiff(expected, actual);
     XmlAssertion.AssertXmlNotIdentical(diff);
 }
 public static void ShouldNotContainXmlEqualTo(this TextReader actual, TextReader expected)
 {
     var diff = new XmlDiff(expected, actual);
     XmlAssertion.AssertXmlNotEquals(diff);
 }
        public void CompareExpectedXMLs()
        {
            Dictionary<string, string> expected = new Dictionary<string, string>();
            Dictionary<string, string> actual = new Dictionary<string, string>();

            RunReport(mValidTrxFile);
            
            XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
            xmlNamespaceManager.AddNamespace("prefix", "urn:model.allure.qatools.yandex.ru");

            DiffConfiguration diffConfiguration = new DiffConfiguration(String.Empty, false, WhitespaceHandling.None, true);
            
            FillCategoryToXmlMap("sample-output", expected);
            FillCategoryToXmlMap(mTargetDir, actual);

            if (expected.Keys.Count != actual.Keys.Count)
            {
                Assert.Fail("Expected {0} categories but found {1}.", expected.Keys.Count, actual.Keys.Count);
            }

            foreach (string category in actual.Keys)
            {
                if (!expected.ContainsKey(category))
                {
                    Assert.Fail("The category " + category + " was not expected.");
                }

                string expectedFile = expected[category];
                string actualFile = actual[category];

                string expectedFileText = File.ReadAllText(expectedFile);
                string actualFileText = File.ReadAllText(actualFile);

                XmlInput control = new XmlInput(expectedFileText);
                XmlInput test = new XmlInput(actualFileText);
                
                XmlDiff xmlDiff = new XmlDiff(control, test, diffConfiguration);
                    
                DiffResult diffResult = xmlDiff.Compare();
                if (!diffResult.Identical)
                {
                    string failureMessage = String.Format("The expected file {0} was different from the actual file {1}", expectedFile, actualFile);
                    failureMessage += Environment.NewLine;
                    failureMessage += "Expected XML: ";
                    failureMessage += expectedFileText;
                    failureMessage += Environment.NewLine;
                    failureMessage += "Actual XML: ";
                    failureMessage += actualFileText;
                    failureMessage += Environment.NewLine;
                    failureMessage += "Difference: ";
                    failureMessage += diffResult.Difference;

                    Assert.Fail(failureMessage);
                }
            }
        }
 private void PerformAssertion(string control, string test, bool assertion)
 {
     var diff = new XmlDiff(control, test);
     PerformAssertion(diff, assertion);
 }
 private void PerformAssertion(XmlDiff diff, bool assertion)
 {
     Assert.Equal(assertion, diff.Compare().Equal);
     Assert.Equal(assertion, diff.Compare().Identical);
 }
 private void PerformAssertion(string control, string test, bool assertion,
                               DiffConfiguration xmlUnitConfiguration)
 {
     var diff = new XmlDiff(new XmlInput(control), new XmlInput(test),
                            xmlUnitConfiguration);
     PerformAssertion(diff, assertion);
 }
 public static void ShouldNotBeXmlEqualTo(this XmlInput actual, XmlInput expected)
 {
     var diff = new XmlDiff(expected, actual);
     XmlAssertion.AssertXmlNotEquals(diff);
 }
Esempio n. 18
0
 private DiffResult PerformDiff(TextReader reader1, TextReader reader2)
 {
     _xmlDiff = new XmlDiff(reader1, reader2);
     DiffResult result = _xmlDiff.Compare();
     return result;
 }