public void Verify_NoObjectEqualsOverride_ShouldThrow() { var verifier = new EquatableVerifier <NoObjectEqualsOverride>() { UniqueItemsFactory = () => new[] { new NoObjectEqualsOverride(1), new NoObjectEqualsOverride(2), new NoObjectEqualsOverride(3), }, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed."); e.ExpectInnerAssertion("Object.Equals must be overridden."); return; } Fail("EquatableVerifier did not throw."); }
public void Verify_BrokenObjectEqualsTrue_ShouldThrow() { var verifier = new EquatableVerifier <BrokenObjectEquals>() { UniqueItemsFactory = () => new[] { new BrokenObjectEquals(1, true), new BrokenObjectEquals(2, true), new BrokenObjectEquals(3, true), }, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed."); e.ExpectInnerAssertion("Object.Equals failed with values expected to not be equal at index 0. Expected: <2>. Actual: <1>."); return; } Fail("EquatableVerifier did not throw."); }
public void Verify_UnstableGetHashCode_ShouldThrow() { var verifier = new EquatableVerifier <UnstableGetHashCode>() { UniqueItemsFactory = () => new[] { new UnstableGetHashCode(1), new UnstableGetHashCode(2), new UnstableGetHashCode(3), }, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed."); e.ExpectInnerAssertion("GetHashCode is not stable."); return; } Fail("EquatableVerifier did not throw."); }
public void Verify_NoEqualityOperators_ShouldThrow() { var verifier = new EquatableVerifier <NoEqualityOperators>() { UniqueItemsFactory = () => new[] { new NoEqualityOperators(1), new NoEqualityOperators(2), new NoEqualityOperators(3), }, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed."); e.ExpectInnerAssertion("Equality operators must be defined."); return; } Fail("EquatableVerifier did not throw."); }
public void Verify_BrokenOpInEquality_ShouldThrow() { var verifier = new EquatableVerifier <BrokenOpInequality>() { UniqueItemsFactory = () => new[] { new BrokenOpInequality(1), new BrokenOpInequality(2), new BrokenOpInequality(3), }, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed."); e.ExpectInnerAssertion("op_Inequality failed with values expected to not be equal at index 0. Expected: <2>. Actual: <1>."); return; } Fail("EquatableVerifier did not throw."); }
public void Verify_String_ShouldNotThrow() { var verifier = new EquatableVerifier <string> { UniqueItemsFactory = () => new[] { "foo", "bar", "baz", }, }; verifier.Verify(); }
public void Verify_Int32_ShouldNotThrow() { var verifier = new EquatableVerifier <int> { UniqueItemsFactory = () => new[] { 1, 2, 3, 4, }, }; verifier.Verify(); }
public void Verify_Correct_ShouldNotThrow() { var verifier = new EquatableVerifier <Correct> { UniqueItemsFactory = () => new[] { new Correct(1), new Correct(2), new Correct(3), }, }; verifier.Verify(); }
public void Verify_NoUniqueItemsFactory_ShouldThrow() { var verifier = new EquatableVerifier <int>(); try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed. UniqueItemsFactory is not set. IsNotNull failed."); return; } Fail("EquatableVerify did not throw."); }
public void Verify_NullUniqueItems_ShouldThrow() { var verifier = new EquatableVerifier <int> { UniqueItemsFactory = () => null, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed. UniqueItemsFactory did not produce any items. IsNotNull failed."); return; } Fail("EquatableVerify did not throw."); }
public void Verify_NullUniqueItem_ShouldThrow() { var verifier = new EquatableVerifier <string> { UniqueItemsFactory = () => new[] { "foo", null, "bar", }, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed. UniqueItemsFactory should not produce null values. AllItemsAreNotNull failed."); return; } Fail("EquatableVerify did not throw."); }
public void Verify_FewerThan3UniqueItems_ShouldThrow() { var verifier = new EquatableVerifier <int> { UniqueItemsFactory = () => new[] { 1, 2, }, }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed. UniqueItemsFactory did not produce 3 or more items. IsTrue failed."); return; } Fail("EquatableVerify did not throw."); }
public void Verify_UnstableUniqueItemsFactory_ShouldThrow() { var items = new[] { 1, 2, 3 }; var verifier = new EquatableVerifier <int> { UniqueItemsFactory = () => items = items.Concat(new[] { 1 }).ToArray(), }; try { verifier.Verify(); } catch (AssertionException e) { e.ExpectMessage("EquatableVerifier failed. UniqueItemsFactory is not stable. IsEqualTo failed. Expected: <4>. Actual: <5>."); return; } Fail("EquatableVerify did not throw."); }