public void ObjectEquals_OtherIsDifferent_NotEqual() { TestValueObject obj1 = new TestValueObject(1, "hello"); TestValueObject obj2 = new TestValueObject(2, "hello"); TestValueObject obj3 = new TestValueObject(1, "hello2"); Assert.False(obj1.Equals(obj2)); Assert.False(obj1.Equals(obj3)); }
public void EqualWhenComponentsAreEqual() { var left = new TestValueObject(1, "caseless", "ABcd"); var right = new TestValueObject(1, "caseLESS", "ABcd"); left.Equals(right as object).Should().BeTrue(); left.Equals(right).Should().BeTrue(); (left == right).Should().BeTrue(); (left != right).Should().BeFalse(); left.GetHashCode().Should().Be(right.GetHashCode()); }
public void NotEqualWhenTheOtherIsNull() { var left = new TestValueObject(1, "caseless", "Blah"); TestValueObject?right = null; left.Equals(right as object).Should().BeFalse(); left.Equals(right).Should().BeFalse(); (left == right).Should().BeFalse(); (left != right).Should().BeTrue(); (right == left).Should().BeFalse(); (right != left).Should().BeTrue(); }
public void NotEqualWhenComponentsAreDifferent( int leftId, string leftCaseless, string leftCaseSensitive, int rightId, string rightCaseless, string rightCaseSensitive ) { var left = new TestValueObject(leftId, leftCaseless, leftCaseSensitive); var right = new TestValueObject(rightId, rightCaseless, rightCaseSensitive); left.Equals(right as object).Should().BeFalse(); left.Equals(right).Should().BeFalse(); (left == right).Should().BeFalse(); (left != right).Should().BeTrue(); }
public void ObjectEqualsShouldBeTrueIfValueObjectsMatchByValue() { TestValueObject valueObject1 = new TestValueObject("Test", 123); TestValueObject valueObject2 = new TestValueObject("Test", 123); valueObject1.Equals((object)valueObject2).Should().BeTrue(); }
public void ObjectEquals_OtherIsEqual_Equal() { TestValueObject obj1 = new TestValueObject(1, "hello"); TestValueObject obj2 = new TestValueObject(1, "hello"); Assert.True(obj1.Equals(obj2)); }
public void ObjectEqualsShouldBeTrueIfValueObjectsAreTheSameReference() { TestValueObject valueObject1 = new TestValueObject("Test", 123); TestValueObject sameReference = valueObject1; valueObject1.Equals((object)sameReference).Should().BeTrue(); }
public void ObjectEquals_OtherIsSame_Equal() { TestValueObject obj1 = new TestValueObject(1, "hello"); // ReSharper disable once EqualExpressionComparison Assert.True(obj1.Equals(obj1)); }
public void EqualsOperatorShouldNotBeTrueIfComparedWithNull() { TestValueObject valueObject1 = new TestValueObject("Test", 123); TestValueObject valueObject2 = null; valueObject1.Equals(valueObject2).Should().BeFalse(); }
public void EqualsShouldNotBeTrueIfValueObjectsDoNotMatchByValue() { TestValueObject valueObject1 = new TestValueObject("Test", 123); TestValueObject valueObject2 = new TestValueObject("Test2", 1234); valueObject1.Equals(valueObject2).Should().BeFalse(); }
public void ObjectEquals_OtherIsDerivedButEqual_NotEqual() { TestValueObject obj1 = new TestValueObject(1, "hello"); TestValueObject obj2 = new DerivedTestValueObject(1, "hello"); Assert.False(obj1.Equals(obj2)); Assert.False(obj2.Equals(obj1)); }
public void should_check_ValueObject_equlity() { TestValueObject regionA = new TestValueObject("Ke", "Kenya"); TestValueObject regionC = new TestValueObject("Ke", "Kenya"); TestValueObject regionB = new TestValueObject("Zm", "Zambia"); Assert.True(regionA.Equals(regionC)); Assert.True(regionB != regionA); }
public void WhenComparingUsingEqualsMethod_ItShouldCompareEquality(TestValueObject a, TestValueObject b, bool expected) { // Act var actual = a.Equals(b); // Assert Assert.Equal(expected, actual); }
public void Should_be_equal_to_another_instance_with_the_same_properties() { //Arrange var sut = new TestValueObject(3, "sadasd asd asdsd p qwevndofgewrio qwrlhw eqhncqw ehtuwehgfqwlerg", Guid.NewGuid(), 2324.52m); var another = new TestValueObject(3, "sadasd asd asdsd p qwevndofgewrio qwrlhw eqhncqw ehtuwehgfqwlerg", sut.C, 2324.52m); //Act var areEqual = sut.Equals(another) && sut == another; //Assert areEqual.Should().BeTrue(); }
public void ObjectEquals_OtherIsNull_NotEqual() { TestValueObject obj1 = new TestValueObject(1, "hello"); Assert.False(obj1.Equals(null)); }
public void ObjectEquals_OtherIsSame_Equal() { TestValueObject obj1 = new TestValueObject(1, "hello"); Assert.True(obj1.Equals((object)obj1)); }
public void IEquatable_OtherIsSame_Equal() { TestValueObject obj1 = new TestValueObject(1, "hello"); Assert.True(obj1.Equals(obj1)); }
public void IEquatable_OtherIsNull_NotEqual() { TestValueObject obj1 = new TestValueObject(1, "hello"); Assert.False(obj1.Equals((ValueObject)null)); }