public static void IsCanonical <T>(this IEquatableAssert assert, IEquatable <T> equatable) { Assert.IsFalse(equatable.Equals(default(T)), CreateMessage("x.Equals(null) == False")); Assert.IsFalse(equatable.Equals(default(object)), CreateMessage("x.Equals(null) == False")); string CreateMessage(string requirement) { return($"{typeof(IEquatable<T>).ToPrettyString()} violates the {requirement.QuoteWith("'")} requirement."); } }
public static void IsCanonical <T>(this IEquatableAssert assert, IEquatable <T> equatable) { // ReSharper disable once EqualExpressionComparison - this is ok, we want this comparison here Assert.IsTrue(equatable.Equals(equatable), CreateMessage("x.Equals(x) == true")); Assert.IsFalse(equatable.Equals(default), CreateMessage("x.Equals(default(T)) == false"));
//public static IEquatableEqualsAssert<T> Equals<T>(this IEquatableAssert<T> assert) => new EquatableAssert<T>(assert.Equatable); //public static void IsTrue<T>(this IEquatableAssert<T> assert, Func<IEquatable<T>, bool> predicate) //{ // Assert.IsTrue(predicate(assert.Equatable), $"The specified condition for {assert.Equatable.Stringify()} must be {bool.TrueString}."); //} public static IEquatableGetHashCodeAssert GetHashCodeMethod(this IEquatableAssert assert) => default(IEquatableGetHashCodeAssert);
public static IEquatableEqualsAssert EqualsMethod(this IEquatableAssert assert) => default(IEquatableEqualsAssert);