public void AddProfile() { var opt = new AutoMapperOptions(); opt.AddProfile <TestProfile>(); var configure = Substitute.For <IAutoMapperConfigurationContext>(); var expression = Substitute.For <IMapperConfigurationExpression>(); configure.Configure().MapperConfiguration.Returns(expression); opt.Configurators.ShouldHaveSingleItem()(configure); configure.Received(1).MapperConfiguration.AddProfile(typeof(TestProfile)); }
public void AddMapsAndValidation() { var opt = new AutoMapperOptions(); opt.AddMaps <AutoMapperTestModule>(true); var configure = Substitute.For <IAutoMapperConfigurationContext>(); var expression = Substitute.For <IMapperConfigurationExpression>(); configure.Configure().MapperConfiguration.Returns(expression); opt.Configurators.ShouldHaveSingleItem()(configure); configure.Received(1).MapperConfiguration.AddMaps(typeof(AutoMapperTestModule).Assembly); opt.ValidatingProfiles.ShouldHaveSingleItem().ShouldBe(typeof(TestProfile)); }
public void ValidateProfile() { var opt = new AutoMapperOptions(); opt.ValidateProfile <TestProfile>(false); opt.ValidatingProfiles.IsNullOrEmpty(); opt.ValidateProfile <TestProfile>(); opt.ValidateProfile <TestProfile>(true); opt.ValidatingProfiles.ShouldHaveSingleItem().ShouldBe(typeof(TestProfile)); opt.ValidateProfile <TestProfile>(); opt.ValidatingProfiles.ShouldHaveSingleItem().ShouldBe(typeof(TestProfile)); opt.ValidatingProfiles.ShouldHaveSingleItem().ShouldBe(typeof(TestProfile)); opt.ValidateProfile <TestProfile>(false); opt.ValidatingProfiles.IsNullOrEmpty(); opt.ValidateProfile <TestProfile>(true); opt.ValidatingProfiles.ShouldHaveSingleItem().ShouldBe(typeof(TestProfile)); opt.ValidateProfile <TestProfile>(true); opt.ValidatingProfiles.ShouldHaveSingleItem().ShouldBe(typeof(TestProfile)); opt.ValidateProfile <TestProfile>(); opt.ValidatingProfiles.ShouldHaveSingleItem().ShouldBe(typeof(TestProfile)); }