public void EqualityOperator_RightNull_FalseReturned() { FakeValueObject left = new FakeValueObject("A"); FakeValueObject right = null; Assert.False(left == right); Assert.True(left != right); }
public void GetHashCode_SingleValue_ThisValueHashCodeReturned() { string singleValue = "abcd"; FakeValueObject obj = new FakeValueObject(singleValue); Assert.Equal(singleValue.GetHashCode(), obj.GetHashCode()); }
public void InequalityOperator_Equal_FalseReturned() { FakeValueObject left = new FakeValueObject("A"); FakeValueObject right = new FakeValueObject("A"); Assert.IsFalse(left != right); }
public void EqualityOperator_BothNulls_TrueReturned() { FakeValueObject left = null; FakeValueObject right = null; Assert.IsTrue(left == right); }
public void Non_null_value_objects_are_not_equal_to_null() { var first = new FakeValueObject(1, "first", true); AssertAreNotEqual(first, null); AssertAreNotEqual(null, first); }
public void Null_value_objects_are_considered_equal() { FakeValueObject first = null; FakeValueObject second = null; AssertAreEqual(first, second); }
public void Value_objects_are_not_equal_if_they_have_at_least_one_private_property_different() { var first = new FakeValueObject(1, "first", true); var second = new FakeValueObject(1, "second", false); AssertAreNotEqual(first, second); }
public void GetHashCode_SingleValue_ThisValueHashCodeReturned() { string singleValue = "abcd"; FakeValueObject obj = new FakeValueObject(singleValue); Assert.AreEqual(singleValue.GetHashCode(), obj.GetHashCode()); }
private static void AssertAreNotEqual( FakeValueObject first, FakeValueObject second) { first.Should().NotBe(second); (first == second).Should().BeFalse(); (first != second).Should().BeTrue(); }
public void Equal_value_objects_have_the_same_hash_code() { var first = new FakeValueObject(1, "first", true); var second = new FakeValueObject(1, "first", true); first.GetHashCode().Should().Be(second.GetHashCode()); }
public void Non_equal_value_objects_have_different_hash_codes() { var a = new FakeValueObject(1, "a", true); var b = new FakeValueObject(2, "a", true); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void equals_operator_should_return_true(string str, int number, DateTime datetime, bool boolean) { // arrange var obj1 = new FakeValueObject { StringValue = str, IntValue = number, DateTimeValue = datetime, BooleanValue = boolean }; var obj2 = new FakeValueObject { StringValue = str, IntValue = number, DateTimeValue = datetime, BooleanValue = boolean }; // Actions var result = obj1 == obj2; var result2 = obj2 == obj1; // Assertion result.Should().BeTrue(); result2.Should().BeTrue(); }
public void GetHashCode_should_return_same(string str, int number, DateTime datetime, bool boolean) { // arrange var obj1 = new FakeValueObject { StringValue = str, IntValue = number, DateTimeValue = datetime, BooleanValue = boolean }; var obj2 = new FakeValueObject { StringValue = str, IntValue = number, DateTimeValue = datetime, BooleanValue = boolean }; // Actions var hash1 = obj1.GetHashCode(); var hash2 = obj2.GetHashCode(); // Assertion hash1.Should().Be(hash2); }
public void Value_objects_are_equal_if_they_have_the_same_properties_and_fields() { var first = new FakeValueObject(1, "first", true); var second = new FakeValueObject(1, "first", true); AssertAreEqual(first, second); }
public void EqualityOperator_RightNull_FalseReturned() { FakeValueObject left = new FakeValueObject("A"); FakeValueObject right = null; Assert.IsFalse(left == right); }
public void InequalityOperator_BothNulls_FalseReturned() { FakeValueObject left = null; FakeValueObject right = null; Assert.IsFalse(left != right); }
public void InequalityOperator_NotEqual_TrueReturned() { FakeValueObject left = new FakeValueObject("B"); FakeValueObject right = new FakeValueObject("A"); Assert.IsTrue(left != right); }
public void GetHashCode_TwoValues_XorOfHashCodesReturned() { string firstValue = "abcd"; int secodValue = 15; FakeValueObject obj = new FakeValueObject(firstValue, secodValue); Assert.Equal((firstValue.GetHashCode() * 1) ^ (secodValue.GetHashCode() * 2), obj.GetHashCode()); }
public void ValueObject_should_throw_BusinessRuleValidationException_when_its_checking_the_rule() { //arrange var vo = new FakeValueObject("Name", 1, false); //act & assert Assert.ThrowsAsync <BusinessRuleValidationException>(() => vo.AsyncMethodThrows_BusinessRuleValidationException(0)); }
public void GetHashCode_TwoValues_XorOfHashCodesReturned() { string firstValue = "abcd"; int secodValue = 15; FakeValueObject obj = new FakeValueObject(firstValue, secodValue); Assert.AreEqual(firstValue.GetHashCode() ^ secodValue.GetHashCode(), obj.GetHashCode()); }
public void ValueObject_should_be_compared_by_values_not_by_references() { //arrange var vo = new FakeValueObject("test", 1, false); var fvo = new FakeValueObject("test", 1, false); //assert vo.Should().Be(fvo); vo.Should().NotBeSameAs(fvo); }
public void SimilarValueObjectsShouldNotHaveSameHashCode() { // Arrange var valueObject1 = new FakeValueObject() { A = 5, B = "Hello" }; var valueObject2 = new FakeValueObject() { A = 6, B = "World" }; // Act var sameHashCode = valueObject1.GetHashCode() == valueObject2.GetHashCode(); // Assert sameHashCode.Should().BeFalse(); }
public void SimilarValueObjectsShouldEquals() { // Arrange var valueObject1 = new FakeValueObject() { A = 5, B = "Hello" }; var valueObject2 = new FakeValueObject() { A = 5, B = "Hello" }; // Act var areEquals = valueObject1 == valueObject2; // Assert areEquals.Should().BeTrue(); }
public void NotSimilarValueObjectsShouldNotEquals() { // Arrange var valueObject1 = new FakeValueObject() { A = 5, B = "Hello" }; var valueObject2 = new FakeValueObject() { A = 6, B = "World" }; // Act var areEquals = valueObject1 == valueObject2; // Assert areEquals.Should().BeFalse(); }
public void GetHashCode_NullValue_ZeroReturned() { var obj = new FakeValueObject(new object[] { null }); Assert.AreEqual(0, obj.GetHashCode()); }
public void EqualityOperator_Equal_TrueReturned() { FakeValueObject left = new FakeValueObject("A"); FakeValueObject right = new FakeValueObject("A"); Assert.IsTrue(left == right); }
public void InequalityOperator_NotEqual_TrueReturned() { var left = new FakeValueObject("B"); var right = new FakeValueObject("A"); Assert.IsTrue(left != right); }
public void InequalityOperator_Equal_FalseReturned() { var left = new FakeValueObject("A"); var right = new FakeValueObject("A"); Assert.IsFalse(left != right); }
public void InequalityOperator_LeftNull_TrueReturned() { FakeValueObject left = null; var right = new FakeValueObject("A"); Assert.IsTrue(left != right); }
public void InequalityOperator_RightNull_TrueReturned() { var left = new FakeValueObject("A"); FakeValueObject right = null; Assert.IsTrue(left != right); }
public void GetHashCode_TwoValues_XorOfHashCodesReturned() { const string firstValue = "abcd"; const int secodValue = 15; var obj = new FakeValueObject(firstValue, secodValue); Assert.AreEqual(firstValue.GetHashCode() ^ secodValue.GetHashCode(), obj.GetHashCode()); }
public void EqualityOperator_LeftNull_FalseReturned() { FakeValueObject left = null; var right = new FakeValueObject("A"); Assert.IsFalse(left == right); }
public void EqualsObjectFailed(FakeValueObject valueObject, object objectToCompare) { valueObject.Equals(objectToCompare).Should().BeFalse(); }
public void EqualityOperator_NotEqual_FalseReturned() { FakeValueObject left = new FakeValueObject("B"); FakeValueObject right = new FakeValueObject("A"); Assert.IsFalse(left == right); }
public void EqualsSucceeds(FakeValueObject valueObject, FakeValueObject valueObjectToCompare) { valueObject.Equals(valueObjectToCompare).Should().BeTrue(); }
public void OperatorNotEqualFailed(FakeValueObject valueObject, FakeValueObject valueObjectToCompare) { (valueObject != valueObjectToCompare).Should().BeFalse(); }
public void OperatorNotEqualSucceeds(FakeValueObject valueObject, FakeValueObject valueObjectToCompare) { (valueObject != valueObjectToCompare).Should().BeTrue(); }
public void Value_objects_are_not_equal_if_they_have_different_types() { var first = new FakeValueObject(1, "first", true); first.Should().NotBe(""); }
public void GetHashCode_NullValue_ZeroReturned() { FakeValueObject obj = new FakeValueObject(new object[] { null }); Assert.AreEqual(0, obj.GetHashCode()); }