Пример #1
0
        public void Mapping_Basic_Poco_Succeeds()
        {
            TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig();

            IAdapter instance = TypeAdapter.GetInstance();
            var      source   = new SimplePoco {
                Id = new Guid(), Name = "Test"
            };

            var destination = instance.Adapt <SimpleDto>(source);

            destination.Name.ShouldEqual(source.Name);
        }
Пример #2
0
        public void Passed_Condition_Primitive_Does_Map()
        {
            TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig()
            .Map(dest => dest.Name, src => src.Name, cond => cond.Name == "TestName");

            var poco = new SimplePoco {
                Id = Guid.NewGuid(), Name = "TestName"
            };

            IAdapter  instance = TypeAdapter.GetInstance();
            SimpleDto dto      = instance.Adapt <SimplePoco, SimpleDto>(poco);

            dto.Id.ShouldEqual(poco.Id);
            dto.Name.ShouldEqual("TestName");
        }
Пример #3
0
        public void False_Condition_Primitive_Does_Not_Map()
        {
            TypeAdapterConfig <SimplePoco, SimpleDto> .NewConfig()
            .Map(dest => dest.Name, src => src.Name, cond => false)
            .Compile();

            var poco = new SimplePoco {
                Id = Guid.NewGuid(), Name = "TestName"
            };

            IAdapter  instance = TypeAdapter.GetInstance();
            SimpleDto dto      = instance.Adapt <SimplePoco, SimpleDto>(poco);

            dto.Id.ShouldBe(poco.Id);
            dto.Name.ShouldBeNull();
        }