Exemplo n.º 1
0
        public void multiple_source_implementations_work()
        {
            var cfg = new DestinationConfigurationContainer(null, new TestConfigurationFactory());

            cfg.Map <DestinationWithSpecialSauce>().From <IWorkOkay, YetAnotherImplementation>();
            var binding = cfg.ToBinding();

            binding.Bind();
            binding.Assert();
            binding.Accept(new CacheInitializer(new Fasterflection()));

            var dest    = new DestinationWithSpecialSauce();
            var cmd1    = binding.CreateCommand(typeof(SourceImplementation), typeof(DestinationWithSpecialSauce));
            var source1 = new SourceImplementation()
            {
                Name = "mikey"
            };

            cmd1.Map(source1, dest);
            dest.Name.should_be_equal_to("mikey");


            dest = new DestinationWithSpecialSauce();
            var cmd2    = binding.CreateCommand(typeof(YetAnotherImplementation), typeof(DestinationWithSpecialSauce));
            var source2 = new YetAnotherImplementation()
            {
                Name = "tasha", SpecialProperty = 3
            };

            cmd2.Map(source2, dest);
            dest.Name.should_be_equal_to("tasha");
            dest.SpecialProperty.should_be_equal_to(3);
        }
Exemplo n.º 2
0
        public void multiple_source_implementations_work()
        {
            var cfg = new DestinationConfigurationContainer(null, new TestConfigurationFactory());
            cfg.Map<DestinationWithSpecialSauce>().From<IWorkOkay,YetAnotherImplementation>();
            var binding = cfg.ToBinding();
            binding.Bind();
            binding.Assert();
            binding.Accept(new CacheInitializer(new Fasterflection()));

            var dest = new DestinationWithSpecialSauce();
            var cmd1 = binding.CreateCommand(typeof(SourceImplementation), typeof(DestinationWithSpecialSauce));
            var source1 = new SourceImplementation() { Name = "mikey" };
            cmd1.Map(source1, dest);
            dest.Name.should_be_equal_to("mikey");

            dest = new DestinationWithSpecialSauce();
            var cmd2 = binding.CreateCommand(typeof(YetAnotherImplementation), typeof(DestinationWithSpecialSauce));
            var source2 = new YetAnotherImplementation() { Name = "tasha" ,SpecialProperty = 3};
            cmd2.Map(source2, dest);
            dest.Name.should_be_equal_to("tasha");
            dest.SpecialProperty.should_be_equal_to(3);
        }