Beispiel #1
0
        public void ShouldResolveDestTypeDescendants()
        {
            var registry = new TypeMapperRegistry();
            var source   = new ClassW2Properties {
                Prop = 1, Prop2 = 2
            };

            var mapper = new TypeMapper <ClassW2Properties, ClassW4PropertiesDescendant1>();

            registry.Register <ClassW2Properties, ClassW4PropertiesDescendant1>(mapper);
            registry.Register <ClassW2Properties, ClassW4PropertiesDescendant2>();
            registry.Register <ClassW2Properties, ClassW4Properties>();

            var dest = registry.ResolveDescendants <ClassW4Properties>(source);

            Assert.IsNotNull(dest);
            Assert.IsTrue(dest.Count() == 3);
            Assert.IsTrue(dest.All(properties => properties.Prop2 == 2));
            Assert.IsTrue(dest.All(properties => properties.Prop == 1));
        }