public static PersonExWithStringCoerce CreatePersonExWithStringCoerce(bool nullDate = false) { PersonExWithStringCoerce p = CreatePersonCore <PersonExWithStringCoerce>(); p.DateOfBirth = nullDate ? (DateTime?)null : DateTime.Now.AddYears(-21); return(p); }
public void CompareCoercesToStringOnAttributedDemand(bool date1Null, bool date2Null) { //Arrange. PersonExWithStringCoerce p1 = ModelsHelper.CreatePersonExWithStringCoerce(date1Null); PersonEx2 p2 = ModelsHelper.CreatePersonEx2(date2Null); ObjectComparer comparer = ObjectComparer.Create <PersonExWithStringCoerce, PersonEx2>(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult propResult = result[nameof(PersonExWithStringCoerce.DateOfBirth)]; propResult.Should().NotBeNull(); (propResult.Result & ComparisonResult.StringCoercion).Should().Be(ComparisonResult.StringCoercion); }