public void AddCustomConventionUsingGenerics([Frozen] Mock <IMapperConfiguration> configurationMock, Mapper.SetupMapping map) { ManualMap <ClassAModel, ClassA> manualMap = null; configurationMock.Setup( x => x.AddMap(It.IsAny <Type>(), It.IsAny <Type>(), It.IsAny <IPropertyMap>())) .Callback <Type, Type, IPropertyMap>((a, b, c) => manualMap = (ManualMap <ClassAModel, ClassA>)c); map.From <ClassAModel>().To <ClassA>().WithCustomConvention <SameNameIgnoreCaseConvention>(); Assert.True(manualMap.Conventions.Count == 1); }
public void AddCustomConversion([Frozen] Mock <IMapperConfiguration> configurationMock, Mapper.SetupMapping map) { ManualMap <ClassAModel, ClassA> manualMap = null; configurationMock.Setup( x => x.AddMap(It.IsAny <Type>(), It.IsAny <Type>(), It.IsAny <IPropertyMap>())) .Callback <Type, Type, IPropertyMap>((a, b, c) => manualMap = (ManualMap <ClassAModel, ClassA>)c); map.From <ClassAModel>().To <ClassA>() .WithCustomConversion <int, string>(i => i.ToString(CultureInfo.CurrentCulture)); Assert.True(manualMap.Conversions.Count == 1); }
public void AddCustomConvention([Frozen] Mock <IMapperConfiguration> configurationMock, Mapper.SetupMapping map) { ManualMap <ClassAModel, ClassA> manualMap = null; configurationMock.Setup( x => x.AddMap(It.IsAny <Type>(), It.IsAny <Type>(), It.IsAny <IPropertyMap>())) .Callback <Type, Type, IPropertyMap>((a, b, c) => manualMap = (ManualMap <ClassAModel, ClassA>)c); map.From <ClassAModel>().To <ClassA>() .WithCustomConvention((s, d) => from destination in d join source in s on destination.Name.ToLower() equals source.Name.ToLower() where source.CanRead && destination.CanWrite select new { source, destination }); Assert.True(manualMap.Conventions.Count == 1); }
public void SetManualMap([Frozen] Mock <IMapperConfiguration> configurationMock, Mapper.SetupMapping map) { ManualMap <ClassAModel, ClassA> manualMap = null; configurationMock.Setup( x => x.AddMap(It.IsAny <Type>(), It.IsAny <Type>(), It.IsAny <IPropertyMap>())) .Callback <Type, Type, IPropertyMap>((a, b, c) => manualMap = (ManualMap <ClassAModel, ClassA>)c); map.From <ClassAModel>().To <ClassA>() .SetManually((s, d) => { d.P1 = s.P1; d.P2 = s.P2; d.P3 = s.P3; }); Assert.NotNull(manualMap.ObjectMap); }
public void AddManualMapWithFromAndThenTo([Frozen] Mock <IMapperConfiguration> configurationMock, Mapper.SetupMapping map) { map.From <ClassAModel>().To <ClassA>(); configurationMock.Verify(x => x.AddMap(It.IsAny <Type>(), It.IsAny <Type>(), It.IsAny <IPropertyMap>()), Times.Once); }
public void AddMapsForInheritanceWithIncludeTo([Frozen] Mock <IMapperConfiguration> configurationMock, Mapper.SetupMapping map) { map.From <ClassAModel>().To <ClassA>().IncludeTo <ClassB>(); configurationMock.Verify(x => x.AddMap(It.IsAny <Type>(), It.IsAny <Type>(), It.IsAny <IPropertyMap>()), Times.Exactly(2)); }