public void CanBeCombinedWithFailingMatcher() { Assert.That(() => Assert.That("foo", Is.StringContaining("bar") & CompareConstraint.IsSimilarTo("")), Throws.TypeOf <AssertionException>()); }
public void TestIsSimilarTo_withFileInput() { ExpectThrows("test1.xml", "test2.xml", () => Assert.That(new StreamSource(TestResources.TESTS_DIR + "test1.xml"), CompareConstraint.IsSimilarTo(new StreamSource(TestResources.TESTS_DIR + "test2.xml")))); }
public void CreatesAUsefulMessageWhenFailingCombinedWithNot() { ExpectThrows("not is similar to the control document", "<a><b></b><c/></a>", () => Assert.That("<a><b></b><c/></a>", !CompareConstraint.IsSimilarTo("<a><b></b><c/></a>"))); }
public void CanBeCombinedWithPassingMatcher() { string xml = "<a><c/><b/></a>"; Assert.That(xml, Is.StringContaining("c") & CompareConstraint.IsSimilarTo("<a><b/><c/></a>") .WithNodeMatcher(new DefaultNodeMatcher(ElementSelectors.ByName))); }
public void TestIsSimilarTo_withDifferenceEvaluator_shouldSucceed() { // prepare TestData string control = "<a><b attr=\"abc\"></b></a>"; string test = "<a><b attr=\"xyz\"></b></a>"; // run Test Assert.That(test, CompareConstraint.IsSimilarTo(control) .WithDifferenceEvaluator(IgnoreAttributeDifferenceEvaluator("attr"))); }
public void TestIsSimilarTo_withComparisonFormatter_shouldFailWithCustomMessage() { string control = "<a><b attr=\"abc\"></b></a>"; string test = "<a><b attr=\"xyz\"></b></a>"; ExpectThrows("DESCRIPTION", "DETAIL-abc", () => Assert.That(test, CompareConstraint .IsSimilarTo(control) .WithComparisonFormatter(new DummyComparisonFormatter()))); }
public void TestDiff_withExtraNodes() { string control = "<a><b></b><c/></a>"; string test = "<a><b></b><c/><d/></a>"; ExpectThrows("Expected child nodelist length '2' but was '3'", "", () => Assert.That(test, CompareConstraint.IsSimilarTo(control))); Assert.That(test, CompareConstraint.IsSimilarTo(control) .WithNodeFilter(n => "d" != n.Name)); }
public void TestDiff_withAttributeDifferences() { string control = "<a><b attr1=\"abc\" attr2=\"def\"></b></a>"; string test = "<a><b attr1=\"xyz\" attr2=\"def\"></b></a>"; ExpectThrows("Expected attribute value 'abc' but was 'xyz'", "", () => Assert.That(test, CompareConstraint.IsSimilarTo(control))); Assert.That(test, CompareConstraint.IsSimilarTo(control) .WithAttributeFilter(a => "attr1" != a.Name)); }
public void TestCompareConstraintWrapper_shouldWriteFailedTestInput() { string control = "<a><b attr=\"abc\"></b></a>"; string test = "<a><b attr=\"xyz\"></b></a>"; string fileName = GetTestResultFolder() + "/testCompareConstraintWrapper.xml"; GetTestResultFolder(); ExpectThrows("Expected attribute value 'abc' but was 'xyz'", "", () => Assert.That(test, TestCompareConstraintWrapper.IsSimilarTo(control) .WithTestFileName(fileName))); Assert.That(new StreamSource(fileName), CompareConstraint.IsSimilarTo(test)); }
public void TestIsSimilarTo_withDifferenceListener_shouldCollectChanges() { CounterComparisonListener comparisonListener = new CounterComparisonListener(); string controlXml = "<a><b>Test Value</b><c>ABC</c></a>"; string testXml = "<a><b><![CDATA[Test Value]]></b><c>XYZ</c></a>"; ExpectThrows("Expected text value 'ABC' but was 'XYZ'", "", () => Assert.That(testXml, CompareConstraint .IsSimilarTo(controlXml) .WithDifferenceListeners(comparisonListener.Notify))); Assert.That(comparisonListener.Differents, Is.EqualTo(1)); Assert.That(comparisonListener.Similars, Is.EqualTo(1)); Assert.That(comparisonListener.Equal, Is.EqualTo(0)); }
public void TestIsSimilarTo_WithErrorForElementOrder_FailsWithExpectedMessage() { Assert.That("<a><c/><b/></a>", CompareConstraint.IsSimilarTo("<a><b/><c/></a>") .WithNodeMatcher(new DefaultNodeMatcher(ElementSelectors.ByNameAndText))); }
public static TestCompareConstraintWrapper IsSimilarTo(object control) { return(new TestCompareConstraintWrapper(CompareConstraint.IsSimilarTo(control))); }
public void CantSetComparisonController() { Assert.That(() => CompareConstraint.IsSimilarTo("<foo/>") .WithComparisonController(null), Throws.TypeOf <NotImplementedException>()); }
public void TestIsSimilarTo_withSwappedElements_shouldSucceed() { Assert.That("<a><c/><b/></a>", CompareConstraint.IsSimilarTo("<a><b/><c/></a>") .WithNodeMatcher(new DefaultNodeMatcher(ElementSelectors.ByNameAndText))); }