示例#1
0
        public void KnowConfigureInjection()
        {
            var modelMapper = new ConventionModelMapper();

            var configurator = modelMapper.InjectionConfigurator <Foo>()
                               .FillProperty(p => p.PropertyString, () => "lorem")
                               .FillProperty(p => p.PropertyDouble, () => 1);

            modelMapper.GetInjector <Foo>().Should().Be(configurator);
        }
示例#2
0
        private IModelMapper CreateModelMapperWithInjection(TestService service)
        {
            var modelMapper = Substitute.For <IModelMapper>();

            IModelMapper mapper   = new ConventionModelMapper();
            var          injecter = mapper.InjectionConfigurator <Foo>()
                                    .FillProperty(p => p.Service, () => service);

            var tableInfo = CreateTableInfo();

            modelMapper.GetTableInfo <Foo>().Returns(tableInfo);
            modelMapper.GetTableInfo(Arg.Any <Type>()).Returns(tableInfo);
            modelMapper.GetInjector <Foo>().Returns(injecter as IInjector);

            return(modelMapper);
        }