public void PrivateSetterInGrandparentWorks()
 {
     var source = new Source {ParentProperty = "ParentProperty", ChildProperty = 1};
     var target = Mapper.Map<Source, GrandChildPrivate>(source);
     target.ParentProperty.ShouldEqual(source.ParentProperty);
     target.ChildProperty.ShouldEqual(source.ChildProperty);
 }
Esempio n. 2
0
        protected override void Establish_context()
        {
            Mapper.Context.Configuration.AllowNullCollections = false;
            Mapper.CreateMap<Source, Destination>();

            _source = new Source {Name = null, Data = null};
        }
        public void Should_map_over_constructor()
        {
            var source = new Source { Value = "value" };

            var dest = Mapper.Map<Destination>(source);

            dest.Value.ShouldEqual(source.Value);
        }
 protected override void Because_of()
 {
     var source = new Source
     {
         Number = 23
     };
     _destination = Mapper.Map<Source, Destination>(source);
 }
 protected override void Because_of()
 {
     var source = new Source
                      {
                          Values = new[] {1, 2, 3, 4},
                          Values2 = new[] {5, 6},
                      };
     _destination = Mapper.Map<Source, Destination>(source);
 }
        public void TestCase()
        {
            var source = new Source() { Name = "Test" };
            var destination = new Destination();

            MicroMapper.Mapper.Map<Source, Destination>(source, destination); // Works

            var subDestination = new SubDestination();

            MicroMapper.Mapper.Map<Source, Destination>(source, subDestination); // Fails
        }
 protected override void Because_of()
 {
     _source = Mapper.Map<Destination, Source>(new Destination
     {
         UserId = SomeId
     });
     _destination = Mapper.Map<Source, Destination>(new Source
     {
         AccountId = SomeOtherId
     });
 }
Esempio n. 8
0
 protected override void Because_of()
 {
     var source = new Source()
     {
         Id = 1,
         ListProperty = _sourceList,
     };
     _destination = new Destination()
     {
         Id = 2,
         ListProperty = new List<int>() { 4, 5, 6 }.Where(a=>true)
     };
     _destination = Mapper.Map<Source, Destination>(source, _destination);
 }
        public void Should_map_all_null_values_to_its_substitute()
        {
            Mapper.CreateMap(typeof(Source), typeof(Destination))
                .ForAllMembers(opt => opt.NullSubstitute(string.Empty));

            var src = new Source
            {
                Value1 = 5
            };

            var dest = Mapper.Map<Source, Destination>(src);

            dest.Value1.ShouldEqual("5");
            dest.Value2.ShouldEqual(string.Empty);
            dest.Value3.ShouldEqual(string.Empty);
        }
Esempio n. 10
0
 public void should_map_over_enumerable_empty()
 {
     var source = new Source { Values = new[] { "1", "2" } };
     var dest = Mapper.Map<DestWithIEnumerableInitializer>(source);
 }
Esempio n. 11
0
 public void should_map_array_inside_object()
 {
     var source = new Source { Values = new[] { "1", "2" } };
     var dest = Mapper.Map<Dest>(source);
 }
Esempio n. 12
0
 protected override void Because_of()
 {
     var source = new Source();
     _destination = new Dest
     {
         Value1 = "Foo",
         Value2 = 10,
         Unmapped = "Asdf"
     };
     Mapper.Map(source, _destination);
 }
 protected override void Because_of()
 {
     var source = new Source { Inner = new Inner { Member = SomeValue } };
     //_dest = Mapper.Map<Source, SourceDto>(source);
     _dest = new[] { source }.AsQueryable().ProjectTo<SourceDto>().First();
 }