Esempio n. 1
0
        public void ConfiguredContainerWithAdditionalsTest()
        {
            var source = new SourceClass();
            var target = new TargetClass();

            Assert.NotEqual(source.Id.ToString(CultureInfo.InvariantCulture), target.Id);
            Assert.NotEqual(source.Name, target.Name);
            Assert.NotEqual(source.SourceDescription, target.TargetDescription);

            var container = Mappings.CreateContainer();

            container.Configure <SourceClass, TargetClass>(map => {
                map.Property(t => t.Id, s => s.Id.ToString(CultureInfo.InvariantCulture));
            });

            source.ApplyTo(target, container, map => {
                map.Property(t => t.TargetDescription, s => s.SourceDescription);
            });

            Assert.Equal(source.Id.ToString(CultureInfo.InvariantCulture), target.Id);
            Assert.Equal(source.Name, target.Name);
            Assert.Equal(source.SourceDescription, target.TargetDescription);
        }