public void CompareCoercesToStringOnDemandFromConfiguration()
        {
            //Arrange.
            PersonEx            p1 = ModelsHelper.CreatePersonEx();
            PersonExWithPropMap p2 = ModelsHelper.CreatePersonExWithPropMapping();
            var config             = ComparerConfigurator.Configure <PersonEx, PersonExWithPropMap>(true)
                                     .MapProperty(src => src.Gender, dst => dst.Gender, true);
            ObjectComparer comparer = config.CreateComparer();

            //Act.
            var result = comparer.Compare(p1, p2, out bool _);

            //Assert.
            result.Should().NotBeNull();
            PropertyComparisonResult pcr = result[nameof(Person.Gender)];

            pcr.Should().NotBeNull();
            (pcr.Result & ComparisonResult.StringCoercion).Should().Be(ComparisonResult.StringCoercion);
            pcr.MapUsed.Should().NotBeNull();
            pcr.MapUsed.ForceStringValue.Should().BeTrue();
            pcr.Value1.Should().NotBeNull();
            pcr.Value1.Should().BeOfType <string>();
            pcr.Value2.Should().NotBeNull();
            pcr.Value2.Should().BeOfType <string>();
        }
        public void ConfigurationIncludesAttributedPropertyMappings()
        {
            //Arrange.
            PersonExWithPropMap p1  = ModelsHelper.CreatePersonExWithPropMapping();
            PersonEx            p2  = ModelsHelper.CreatePersonEx();
            var            config   = ComparerConfigurator.Configure <PersonExWithPropMap, PersonEx>();
            ObjectComparer comparer = config.CreateComparer();

            //Act.
            var result = comparer.Compare(p1, p2, out bool _);

            //Assert.
            result[nameof(PersonExWithPropMap.NewNickName)].MapUsed.Should().NotBeNull();
        }
        public void CompareUsesMappingsFromConfiguration()
        {
            //Arrange.
            PersonEx            p1 = ModelsHelper.CreatePersonEx();
            PersonExWithPropMap p2 = ModelsHelper.CreatePersonExWithPropMapping();
            var config             = ComparerConfigurator.Configure <PersonEx, PersonExWithPropMap>(true)
                                     .MapProperty(src => src.NickName, dst => dst.NewNickName);
            ObjectComparer comparer = config.CreateComparer();

            //Act.
            var result = comparer.Compare(p1, p2, out bool _);

            //Assert.
            result.Should().NotBeNull();
            PropertyMap map = result[nameof(PersonEx.NickName)].MapUsed;

            map.Should().NotBeNull();
            map.TargetType.Should().Be(typeof(PersonExWithPropMap));
            map.TargetProperty.Should().Be(nameof(PersonExWithPropMap.NewNickName));
        }
        public void CompareUsesComparersFromConfiguration()
        {
            //Arrange.
            PersonEx            p1             = ModelsHelper.CreatePersonEx();
            PersonExWithPropMap p2             = ModelsHelper.CreatePersonExWithPropMapping();
            Mock <IComparer>    customComparer = new Mock <IComparer>();

            customComparer.Setup(m => m.Compare(It.IsAny <Genders>(), It.IsAny <object>()))
            .Returns(-1)
            .Verifiable($"{nameof(IComparer.Compare)}() method was not invoked.");
            var config = ComparerConfigurator.Configure <PersonEx, PersonExWithPropMap>(true)
                         .MapProperty(src => src.NickName, dst => dst.NewNickName)
                         .AddComparer <Genders>(customComparer.Object);

            ;
            ObjectComparer comparer = config.CreateComparer();

            //Act.
            var result = comparer.Compare(p1, p2, out bool _);

            //Assert.
            result.Should().NotBeNull();
            customComparer.VerifyAll();
        }