コード例 #1
0
 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);
 }
コード例 #2
0
        protected override void Establish_context()
        {
            Mapper.Context.Configuration.AllowNullCollections = false;
            Mapper.CreateMap<Source, Destination>();

            _source = new Source {Name = null, Data = null};
        }
コード例 #3
0
        public void Should_map_over_constructor()
        {
            var source = new Source { Value = "value" };

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

            dest.Value.ShouldEqual(source.Value);
        }
コード例 #4
0
 protected override void Because_of()
 {
     var source = new Source
     {
         Number = 23
     };
     _destination = Mapper.Map<Source, Destination>(source);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
        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
        }
コード例 #7
0
 protected override void Because_of()
 {
     _source = Mapper.Map<Destination, Source>(new Destination
     {
         UserId = SomeId
     });
     _destination = Mapper.Map<Source, Destination>(new Source
     {
         AccountId = SomeOtherId
     });
 }
コード例 #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);
 }
コード例 #9
0
        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);
        }
コード例 #10
0
 public void should_map_over_enumerable_empty()
 {
     var source = new Source { Values = new[] { "1", "2" } };
     var dest = Mapper.Map<DestWithIEnumerableInitializer>(source);
 }
コード例 #11
0
 public void should_map_array_inside_object()
 {
     var source = new Source { Values = new[] { "1", "2" } };
     var dest = Mapper.Map<Dest>(source);
 }
コード例 #12
0
ファイル: IgnoreAll.cs プロジェクト: mwpowellhtx/MicroMapper
 protected override void Because_of()
 {
     var source = new Source();
     _destination = new Dest
     {
         Value1 = "Foo",
         Value2 = 10,
         Unmapped = "Asdf"
     };
     Mapper.Map(source, _destination);
 }
コード例 #13
0
 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();
 }