public void ReferenceEqualityWorksCorrectly() { // Arrange var sut = new GameVersionRange(new GameVersionBound(), new GameVersionBound()); // Act var genericEquals = sut.Equals(sut); var nonGenericEquals = sut.Equals((object)sut); // Assert Assert.IsTrue(genericEquals); Assert.IsTrue(nonGenericEquals); }
public void EqualityWorksCorrectly(GameVersionRange vr1, GameVersionRange vr2, bool areEqual) { // Act var genericEquals = vr1.Equals(vr2); var nonGenericEquals = vr1.Equals((object)vr2); var equalsOperator = vr1 == vr2; var notEqualsOperator = vr1 != vr2; var reverseEqualsOperator = vr2 == vr1; var reverseNotEqualsOperator = vr2 != vr1; // Assert Assert.AreEqual(areEqual, genericEquals); Assert.AreEqual(areEqual, nonGenericEquals); Assert.AreEqual(areEqual, equalsOperator); Assert.AreNotEqual(areEqual, notEqualsOperator); Assert.AreEqual(areEqual, reverseEqualsOperator); Assert.AreNotEqual(areEqual, reverseNotEqualsOperator); }
public void NullEqualityWorksCorrectly() { // Arrange var sut = new GameVersionRange(new GameVersionBound(), new GameVersionBound()); // Act // ReSharper disable ConditionIsAlwaysTrueOrFalse var genericEquals = sut.Equals(null); var nonGenericEquals = sut.Equals((object)null); var equalsOperatorNullLeft = null == sut; var equalsOperatorNullRight = sut == null; var notEqualsOperatorNullLeft = null != sut; var notEqualsOperatorNullRight = sut != null; // ReSharper restore ConditionIsAlwaysTrueOrFalse // ASsert Assert.IsFalse(genericEquals); Assert.IsFalse(nonGenericEquals); Assert.IsFalse(equalsOperatorNullLeft); Assert.IsFalse(equalsOperatorNullRight); Assert.IsTrue(notEqualsOperatorNullLeft); Assert.IsTrue(notEqualsOperatorNullRight); }