Пример #1
0
        public void it_should_handle_collections_natively()
        {
            var src = new CollectionSource {
                Name = "mikey", List = new List <string> {
                    "one", "two"
                }
            };
            var cfg = new DestinationConfiguration(typeof(CollectionDestination));

            cfg.From(typeof(CollectionSource));
            var executable = cfg.ToExecutable(src.GetType());
            var mapper     = new DefaultMapCommand(executable, new TestContextualizer());
            var dest       = (CollectionDestination)mapper.From(src);

            dest.Name.should_be_equal_to("mikey");
            dest.List.should_not_be_null();
            dest.List.Count.should_be_equal_to(2);
            dest.List[0].should_be_equal_to("one");
            dest.List[1].should_be_equal_to("two");
        }
Пример #2
0
        public void it_can_map_list_of_nullable_double_to_nonnullable_double_list()
        {
            var cfg = new DestinationConfiguration(typeof(CollectionDestination));

            cfg.From(typeof(CollectionSource));
            var src = new CollectionSource()
            {
                MyDoubles = new List <double?> {
                    2.1, null, 3.2
                }
            };
            var executable = cfg.ToExecutable(src.GetType());
            var mapper     = new DefaultMapCommand(executable, new TestContextualizer());
            var output     = (CollectionDestination)mapper.From(src);

            output.MyDoubles.Count.should_be_equal_to(3);
            output.MyDoubles[0].should_be_equal_to(2.1);
            output.MyDoubles[1].should_be_equal_to(0);
            output.MyDoubles[2].should_be_equal_to(3.2);
        }
Пример #3
0
 public void it_should_handle_collections_natively()
 {
     var src = new CollectionSource {Name = "mikey", List = new List<string> {"one", "two"}};
     var cfg = new DestinationConfiguration(typeof(CollectionDestination));
     cfg.From(typeof (CollectionSource));
     var executable = cfg.ToExecutable(src.GetType());
     var mapper = new DefaultMapCommand(executable, new TestContextualizer());
     var dest = (CollectionDestination)mapper.From(src);
     dest.Name.should_be_equal_to("mikey");
     dest.List.should_not_be_null();
     dest.List.Count.should_be_equal_to(2);
     dest.List[0].should_be_equal_to("one");
     dest.List[1].should_be_equal_to("two");
 }
Пример #4
0
 public void it_can_map_list_of_nullable_double_to_nonnullable_double_list()
 {
     var cfg = new DestinationConfiguration(typeof(CollectionDestination));
     cfg.From(typeof (CollectionSource));
     var src = new CollectionSource() {MyDoubles = new List<double?> {2.1, null, 3.2}};
     var executable = cfg.ToExecutable(src.GetType());
     var mapper = new DefaultMapCommand(executable, new TestContextualizer());
     var output = (CollectionDestination) mapper.From(src);
     output.MyDoubles.Count.should_be_equal_to(3);
     output.MyDoubles[0].should_be_equal_to(2.1);
     output.MyDoubles[1].should_be_equal_to(0);
     output.MyDoubles[2].should_be_equal_to(3.2);
 }