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);
        }
Esempio n. 2
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);
        }
        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);
        }