Пример #1
0
        public void ShouldMapProperties()
        {
            DefineMap.From<FlatFrom>().To<FlatTo>()
                .Map(from => from.Value, to => to.Value);

            FlatFrom source = new FlatFrom() { Value = 123 };
            FlatTo destination = Map.From<FlatFrom>(source).To<FlatTo>();
            Assert.AreEqual(source.Value, destination.Value, "The value was not mapped.");
        }
Пример #2
0
        public void ShouldMapPropertiesUsingNamedMapping()
        {
            const string identifier = "Multiply Ints";
            DefineMap.From<FlatFrom>().To<FlatTo>(identifier)
                .Map(from => from.Value, (to, value) => to.Value = value * 2);

            FlatFrom source = new FlatFrom() { Value = 123 };
            FlatTo destination = Map.From<FlatFrom>(source).To<FlatTo>(identifier);
            Assert.AreEqual(source.Value * 2, destination.Value, "The value was not mapped.");
        }