Ejemplo n.º 1
0
        public void MissingSourceMember()
        {
            var srcEntity = new PartialEntity
            {
                Name = "Slim"
            };

            var mapper = new Mapper();

            mapper
            .Invoking(x => x.Map <PartialEntity, DestEntity>(srcEntity))
            .Should().Throw <MissingMemberException>();
        }
Ejemplo n.º 2
0
        public void IgnoreMissingSourceMember()
        {
            var srcEntity = new PartialEntity
            {
                Name = "Slim"
            };

            var mapper = new Mapper();

            mapper.Register <PartialEntity, CtorEntity>().Ignore(x => x.Val);
            var destEntity = mapper.Map <PartialEntity, CtorEntity>(srcEntity);

            Assert.AreEqual("Slim", destEntity.Name);
            Assert.AreEqual(CtorEntity.TheValue, destEntity.Val);
        }
Ejemplo n.º 3
0
        public void MissingSourceMemberWithConfiguration()
        {
            const int V         = 100500;
            var       srcEntity = new PartialEntity
            {
                Name = "Slim"
            };

            var mapper = new Mapper();

            mapper.Register <PartialEntity, DestEntity>().Configure(x => x.Val, part => V);
            var destEntity = mapper.Map <PartialEntity, DestEntity>(srcEntity);

            Assert.AreEqual("Slim", destEntity.Name);
            Assert.AreEqual(V, destEntity.Val);
        }