Esempio n. 1
0
        public void ShouldMapOneToTwo()
        {
            var config = new ConfigurationStore(new TypeMapFactory(), MapperRegistry.AllMappers());

            config.CreateMap <One, Two>();

            config.CreateMap <IEnumerable <string>, IEnumerable <Item> >().ConvertUsing <StringToItemConverter>();

            config.AssertConfigurationIsValid();

            var engine = new MappingEngine(config);
            var one    = new One
            {
                Stuff = new List <string> {
                    "hi", "", "mom"
                }
            };

            var two = engine.Map <One, Two>(one);

            two.ShouldNotBeNull();
            two.Stuff.Count().ShouldEqual(2);
        }
        public void ShouldMapOneToTwo()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <One, Two>();

                cfg.CreateMap <IEnumerable <string>, IEnumerable <Item> >().ConvertUsing <StringToItemConverter>();
            });

            config.AssertConfigurationIsValid();

            var engine = config.CreateMapper();
            var one    = new One
            {
                Stuff = new List <string> {
                    "hi", "", "mom"
                }
            };

            var two = engine.Map <One, Two>(one);

            two.ShouldNotBeNull();
            two.Stuff.Count().ShouldBe(2);
        }