Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }