public void Setup()
        {
            this.objA = new GenericDomain<int[,]> { GenericProp = this.CreateArray() };
            this.objB = new GenericDomain<int[,]> { GenericProp = this.CreateArray() };

            this.comparator = new ObjectComparator<GenericDomain<int[,]>>();
        }
        public void ThenShouldPassIfValuesAreEqual()
        {
            var comparator = Extensions.CreateComparator<GenericDomain<DateTime>>();

            var objA = new GenericDomain<DateTime> {GenericProp = DateTime.Parse("1/1/2001 14:55:33")};
            var objB = new GenericDomain<DateTime> {GenericProp = DateTime.Parse("1/1/2001 14:55:33")};

            var result = comparator.Compare(objA, objB);
            result.AreSame.Should().BeTrue();
        }
        public void ThenShouldFailIfValuesDiffer()
        {
            var comparator = Extensions.CreateComparator<GenericDomain<DateTime>>();

            var objA = new GenericDomain<DateTime> { GenericProp = DateTime.Parse("1/1/2001 14:55:33") };
            var objB = new GenericDomain<DateTime> { GenericProp = DateTime.Parse("1/1/2001 14:55:34") };

            var result = comparator.Compare(objA, objB);
            result.AreSame.Should().BeFalse();
            result.Differences.Single().PropertyPath.Should().Be("GenericProp");
        }
        public void ThenShouldFailIfDoubleValuesDifferByMoreThanEpsilon()
        {
            var comparator = Extensions.CreateComparator<GenericDomain<double>>();

            var objA = new GenericDomain<double> { GenericProp = 0 };
            var objB = new GenericDomain<double> { GenericProp = 1 };

            var result = comparator.Compare(objA, objB);
            result.AreSame.Should().BeFalse();
            result.Differences.Single().PropertyPath.Should().Be("GenericProp");
        }
        public void ThenShouldPassIfFloatValuesAreSame()
        {
            var comparator = Extensions.CreateComparator<GenericDomain<float>>();

            var value = 0.00000001f;
            var objA = new GenericDomain<float> { GenericProp = value };
            var objB = new GenericDomain<float> { GenericProp = value };

            var result = comparator.Compare(objA, objB);
            result.AreSame.Should().BeTrue();
        }
        public void ThenShouldPassIfDoubleValuesDifferByLessThanEpsilon()
        {
            var comparator = Extensions.CreateComparator<GenericDomain<double>>();

            comparator
                .PropertiesOfType<double>()
                .WithEpsilon(0.001f);

            var objA = new GenericDomain<double> { GenericProp = 0.00000001f };
            var objB = new GenericDomain<double> { GenericProp = 0.00000002f };

            var result = comparator.Compare(objA, objB);
            result.AreSame.Should().BeTrue();
        }
        public void ThenShouldNotCompareNestedPropertiesIfInstancesAreReferenceEqual()
        {
            var genericDomainComparator = Extensions.CreateComparator<GenericDomain<ThrowingDomain>>();

            var throwing = new ThrowingDomain();
            var objA = new GenericDomain<ThrowingDomain> { GenericProp = throwing };
            var objB = new GenericDomain<ThrowingDomain> { GenericProp = throwing };

            var result = genericDomainComparator.Compare(objA, objB);
            result.AreSame.Should().BeTrue();
        }
 public void Setup()
 {
     this.objA = new GenericDomain<int?>();
     this.objB = new GenericDomain<int?>();
     this.comparator = Extensions.CreateComparator<GenericDomain<int?>>();
 }
 public void Setup()
 {
     this.objA = new GenericDomain<object>();
     this.objB = new GenericDomain<object>();
     this.comparator = new ObjectComparator<GenericDomain<object>>();
 }