コード例 #1
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);
        }
コード例 #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);
                }
            }
        }
        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);
                }
            }
        }