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());
        }
Esempio n. 3
0
        public void InequalityOperator_Equal_FalseReturned()
        {
            FakeValueObject left  = new FakeValueObject("A");
            FakeValueObject right = new FakeValueObject("A");

            Assert.IsFalse(left != right);
        }
Esempio n. 4
0
        public void EqualityOperator_BothNulls_TrueReturned()
        {
            FakeValueObject left  = null;
            FakeValueObject right = null;

            Assert.IsTrue(left == right);
        }
Esempio n. 5
0
        public void Non_null_value_objects_are_not_equal_to_null()
        {
            var first = new FakeValueObject(1, "first", true);

            AssertAreNotEqual(first, null);
            AssertAreNotEqual(null, first);
        }
Esempio n. 6
0
        public void Null_value_objects_are_considered_equal()
        {
            FakeValueObject first  = null;
            FakeValueObject second = null;

            AssertAreEqual(first, second);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        public void GetHashCode_SingleValue_ThisValueHashCodeReturned()
        {
            string          singleValue = "abcd";
            FakeValueObject obj         = new FakeValueObject(singleValue);

            Assert.AreEqual(singleValue.GetHashCode(), obj.GetHashCode());
        }
Esempio n. 9
0
 private static void AssertAreNotEqual(
     FakeValueObject first, FakeValueObject second)
 {
     first.Should().NotBe(second);
     (first == second).Should().BeFalse();
     (first != second).Should().BeTrue();
 }
Esempio n. 10
0
        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());
        }
Esempio n. 11
0
        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());
        }
Esempio n. 12
0
        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();
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        public void EqualityOperator_RightNull_FalseReturned()
        {
            FakeValueObject left  = new FakeValueObject("A");
            FakeValueObject right = null;

            Assert.IsFalse(left == right);
        }
Esempio n. 16
0
        public void InequalityOperator_BothNulls_FalseReturned()
        {
            FakeValueObject left  = null;
            FakeValueObject right = null;

            Assert.IsFalse(left != right);
        }
Esempio n. 17
0
        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());
        }
Esempio n. 19
0
        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));
        }
Esempio n. 20
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());
        }
Esempio n. 21
0
        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();
        }
Esempio n. 25
0
        public void GetHashCode_NullValue_ZeroReturned()
        {
            var obj = new FakeValueObject(new object[] { null });

            Assert.AreEqual(0, obj.GetHashCode());
        }
Esempio n. 26
0
 public void EqualityOperator_Equal_TrueReturned()
 {
    FakeValueObject left = new FakeValueObject("A");
    FakeValueObject right = new FakeValueObject("A");
    Assert.IsTrue(left == right);
 }
Esempio n. 27
0
 public void InequalityOperator_NotEqual_TrueReturned()
 {
     var left = new FakeValueObject("B");
     var right = new FakeValueObject("A");
     Assert.IsTrue(left != right);
 }
Esempio n. 28
0
 public void InequalityOperator_Equal_FalseReturned()
 {
     var left = new FakeValueObject("A");
     var right = new FakeValueObject("A");
     Assert.IsFalse(left != right);
 }
Esempio n. 29
0
 public void InequalityOperator_LeftNull_TrueReturned()
 {
     FakeValueObject left = null;
     var right = new FakeValueObject("A");
     Assert.IsTrue(left != right);
 }
Esempio n. 30
0
 public void InequalityOperator_RightNull_TrueReturned()
 {
     var left = new FakeValueObject("A");
     FakeValueObject right = null;
     Assert.IsTrue(left != right);
 }
Esempio n. 31
0
        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());
        }
Esempio n. 32
0
 public void EqualityOperator_LeftNull_FalseReturned()
 {
     FakeValueObject left = null;
     var right = new FakeValueObject("A");
     Assert.IsFalse(left == right);
 }
Esempio n. 33
0
 public void EqualsObjectFailed(FakeValueObject valueObject, object objectToCompare)
 {
     valueObject.Equals(objectToCompare).Should().BeFalse();
 }
Esempio n. 34
0
 public void EqualityOperator_NotEqual_FalseReturned()
 {
    FakeValueObject left = new FakeValueObject("B");
    FakeValueObject right = new FakeValueObject("A");
    Assert.IsFalse(left == right);
 }
Esempio n. 35
0
 public void EqualsSucceeds(FakeValueObject valueObject, FakeValueObject valueObjectToCompare)
 {
     valueObject.Equals(valueObjectToCompare).Should().BeTrue();
 }
Esempio n. 36
0
 public void OperatorNotEqualFailed(FakeValueObject valueObject, FakeValueObject valueObjectToCompare)
 {
     (valueObject != valueObjectToCompare).Should().BeFalse();
 }
Esempio n. 37
0
 public void OperatorNotEqualSucceeds(FakeValueObject valueObject, FakeValueObject valueObjectToCompare)
 {
     (valueObject != valueObjectToCompare).Should().BeTrue();
 }
Esempio n. 38
0
        public void Value_objects_are_not_equal_if_they_have_different_types()
        {
            var first = new FakeValueObject(1, "first", true);

            first.Should().NotBe("");
        }
Esempio n. 39
0
        public void GetHashCode_NullValue_ZeroReturned()
        {
            FakeValueObject obj = new FakeValueObject(new object[] { null });

            Assert.AreEqual(0, obj.GetHashCode());
        }