public void ThrowIfNotEqual_WithComparer_ShouldNotThrowException() { var left = new ItemTest() { Value = 4 }; var right = new ItemTest() { Value = 4 }; Contract.ThrowIfNotEqual(left, right, new ItemTestEqualityComparer()); }
public void ThrowIfEqual_ReferenceComparerWIthMessage_ShouldNotThrowException() { const string message = "a useful message."; var left = new ItemTest() { Value = 4 }; var right = new ItemTest() { Value = 4 }; Contract.ThrowIfEqual(left, right, message); }
public void ThrowIfEqual_WithComparerAndMessage() { const string message = "a useful message."; var left = new ItemTest() { Value = 4 }; var right = new ItemTest() { Value = 4 }; var exception = Assert.Throws <ErrorException>(() => Contract.ThrowIfEqual(left, right, new ItemTestEqualityComparer(), null, message)); Assert.NotNull(exception); Assert.True(exception.Message.StartsWith(message)); Assert.AreEqual(exception.Error, ContractError.ThrowIfEqual.ToError(left.ToSafeString(), right.ToSafeString())); }