From 63fdc94d2e820fd3bbc81525e3beac34046bf3a5 Mon Sep 17 00:00:00 2001 From: Olivia Date: Tue, 20 Dec 2016 13:52:27 +0200 Subject: [PATCH] Adding equality and not equality tests on concrete object type. --- .../Colors/ColorEqualityTests.cs | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs b/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs index fdf47015c..c8a3cf38d 100644 --- a/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs +++ b/tests/ImageSharp.Tests/Colors/ColorEqualityTests.cs @@ -142,16 +142,38 @@ namespace ImageSharp.Tests.Colors [Theory] [MemberData(nameof(EqualityData))] - public void EqualityOperator(object first, object second, Type type) + public void EqualityObject(object first, object second, Type type) { // Arrange - // Cast to the known object types + // Cast to the known object types, this is so that we can hit the + // equality operator on the concrete type, otherwise it goes to the + // default "object" one :) + var firstObject = Convert.ChangeType(first, type); + var secondObject = Convert.ChangeType(second, type); // Act - var equal = first.Equals(second); + var equal = firstObject.Equals(secondObject); // Assert Assert.True(equal); } + + [Theory] + [MemberData(nameof(NotEqualityData))] + public void NotEqualityObject(object first, object second, Type type) + { + // Arrange + // Cast to the known object types, this is so that we can hit the + // equality operator on the concrete type, otherwise it goes to the + // default "object" one :) + var firstObject = Convert.ChangeType(first, type); + var secondObject = Convert.ChangeType(second, type); + + // Act + var equal = firstObject.Equals(secondObject); + + // Assert + Assert.False(equal); + } } }