public void CheckAndRecord(ConstraintsViolations violations)
        {
            RecordedAssertions.DoesNotThrow(() =>
            {
                var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();
                var instance2 = _activator.CreateInstanceAsValueObjectWithPreviousParameters();

                //TODO how to test equatable???
                RecordedAssertions.DoesNotThrow(() =>
                                                RecordedAssertions.True(instance1.Equals(instance2),
                                                                        "a.Equals(b) should return true if both are created with the same arguments", violations),
                                                "a.Equals(b) should return true if both are created with the same arguments", violations);
                RecordedAssertions.DoesNotThrow(() =>
                                                RecordedAssertions.True(instance2.Equals(instance1),
                                                                        "b.Equals(a) should return true if both are created with the same arguments", violations),
                                                "b.Equals(a) should return true if both are created with the same arguments", violations);

                RecordedAssertions.DoesNotThrow(() =>
                                                RecordedAssertions.True(instance1.Equals(instance2),
                                                                        "(object)a.Equals((object)b) should return true if both are created with the same arguments", violations),
                                                "(object)a.Equals((object)b) should return true if both are created with the same arguments", violations);
                RecordedAssertions.DoesNotThrow(() =>
                                                RecordedAssertions.True(instance2.Equals(instance1),
                                                                        "(object)b.Equals((object)a) should return true if both are created with the same arguments", violations),
                                                "(object)b.Equals((object)a) should return true if both are created with the same arguments", violations);
            }, "Should be able to create an object of type " + _activator.TargetType, violations);
        }
コード例 #2
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            for (var i = 0; i < _activator.GetConstructorParametersCount(); ++i)
            {
                var currentParamIndex = i;

                if (ArgumentIsPartOfValueIdentity(i))
                {
                    var instance2 = _activator.CreateInstanceAsValueObjectWithModifiedParameter(i);

                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.False(instance1.Equals(instance2),
                                                                             "a.Equals(b) should return false if both are created with different argument" + currentParamIndex, violations),
                                                    "a.Equals(b) should return false if both are created with different argument" + currentParamIndex, violations);
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.False(instance2.Equals(instance1),
                                                                             "b.Equals(a) should return false if both are created with different argument" + currentParamIndex, violations),
                                                    "b.Equals(a) should return false if both are created with different argument" + currentParamIndex, violations);
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.False(instance1.Equals(instance2),
                                                                             "(object)a.Equals((object)b) should return false if both are created with different argument" + currentParamIndex, violations),
                                                    "(object)a.Equals((object)b) should return false if both are created with different argument" + currentParamIndex, violations);
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.False(instance2.Equals(instance1),
                                                                             "(object)b.Equals((object)a) should return false if both are created with different argument" + currentParamIndex, violations),
                                                    "(object)b.Equals((object)a) should return false if both are created with different argument" + currentParamIndex, violations);
                }
            }
        }
コード例 #3
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();
            var instance3 = _activator.CreateInstanceAsValueObjectWithPreviousParameters();

            for (var i = 0; i < _activator.GetConstructorParametersCount(); ++i)
            {
                if (ArgumentIsPartOfValueIdentity(i))
                {
                    var instance2 = _activator.CreateInstanceAsValueObjectWithModifiedParameter(i);
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.NotEqual(instance1.GetHashCode(), instance2.GetHashCode(),
                                                                                "b.GetHashCode() and b.GetHashCode() should return different values when both are created with different argument" + i, violations),
                                                    "b.GetHashCode() and b.GetHashCode() should return different values when both are created with different argument" + i, violations);
                }
            }

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.Equal(instance1.GetHashCode(), instance3.GetHashCode(),
                                                                     "a.GetHashCode() and b.GetHashCode() should return same values when both are created with same arguments", violations),
                                            "a.GetHashCode() and b.GetHashCode() should return same values when both are created with same arguments", violations);
            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.Equal(instance1.GetHashCode(), instance3.GetHashCode(),
                                                                     "a.GetHashCode() and b.GetHashCode() should return same values when both are created with same arguments", violations),
                                            "a.GetHashCode() and b.GetHashCode() should return same values when both are created with same arguments", violations);
        }
コード例 #4
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.True(Are.EqualInTermsOfEqualityOperator(_activator.TargetType, instance1, instance1),
                                                                    "a == a should return true", violations), "a == a should return true", violations);
        }
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.False(instance1.Equals(null),
                                                                     "a.Equals(null) should return false", violations),
                                            "a.Equals(null) should return false", violations);
        }
 public void CheckAndRecord(ConstraintsViolations violations)
 {
     RecordedAssertions.DoesNotThrow(() =>
     {
         var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();
         RecordedAssertions.DoesNotThrow(() =>
                                         RecordedAssertions.True(instance1.Equals(instance1),
                                                                 "a.Equals(a) should return true", violations),
                                         "a.Equals(a) should return true", violations);
     }, "Should be able to create an object of type " + _activator.TargetType, violations);
 }
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();
            var instance2 = _activator.CreateInstanceAsValueObjectWithPreviousParameters();

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.False(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, instance2),
                                                                     "a != b should return false if both are created with the same arguments", violations),
                                            "a != b should return false if both are created with the same arguments", violations);
            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.False(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance2, instance1),
                                                                     "b != a should return false if both are created with the same arguments", violations),
                                            "b != a should return false if both are created with the same arguments", violations);
        }
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            for (var i = 0; i < _activator.GetConstructorParametersCount(); ++i)
            {
                if (ArgumentIsPartOfValueIdentity(i))
                {
                    var instance2 = _activator.CreateInstanceAsValueObjectWithModifiedParameter(i);

                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, instance2),
                                                                            "a != b should return true if both are created with different argument" + i, violations),
                                                    "a != b should return true if both are created with different argument" + i, violations);
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, instance2),
                                                                            "b != a should return true if both are created with different argument" + i, violations),
                                                    "b != a should return true if both are created with different argument" + i, violations);
                }
            }
        }
コード例 #9
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, null),
                                                                    "a != null should return true", violations),
                                            "a != null should return true", violations);
            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, null, instance1),
                                                                    "null != a should return true", violations),
                                            "null != a should return true", violations);

            //TODO remove?
            object null1 = null;
            object null2 = null;

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.False(null1 != null2,
                                                                     "null != null should be false", violations),
                                            "null != null should be false", violations);
        }