Exemplo n.º 1
0
        public void NestedNullTest()
        {
            var mapper = new Mapper();

            mapper.Register <CompositionEntity, CompositionDestEntity>();
            mapper.Register <SrcEntity, DestEntity>();

            var entity = new CompositionEntity
            {
                NestedEntity = null
            };

            var compositionDestEntity = mapper.Map <CompositionEntity, CompositionDestEntity>(entity);

            Assert.IsNull(compositionDestEntity.NestedEntity);
        }
Exemplo n.º 2
0
        public void NestedTest()
        {
            var mapper = new Mapper();

            mapper.Register <CompositionEntity, CompositionDestEntity>();
            mapper.Register <SrcEntity, DestEntity>();

            var entity = new CompositionEntity
            {
                NestedEntity = new SrcEntity
                {
                    Name = "Slippage",
                    Val  = 505
                }
            };

            var compositionDestEntity = mapper.Map <CompositionEntity, CompositionDestEntity>(entity);

            Assert.IsInstanceOf <DestEntity>(compositionDestEntity.NestedEntity);
            Assert.AreEqual("Slippage", compositionDestEntity.NestedEntity.Name);
            Assert.AreEqual(505, compositionDestEntity.NestedEntity.Val);
        }