예제 #1
0
        public void ConversionTest()
        {
            var source = new PlainSourceClass {
                Id = 1, Name = "Test", SourceFieldOnly = "source"
            };
            var destination = _mapper.Map <PlainSourceClass, ConversionDestinationClass>(source);

            Assert.That(destination.Id, Is.EqualTo(source.Id.ToString()));
            Assert.That(destination.Name, Is.EqualTo(source.Name));
        }
예제 #2
0
        public void PlainTest()
        {
            var source = new PlainSourceClass {
                Id = 1, Name = "Test", SourceFieldOnly = "source"
            };
            var destination = _mapper.Map <PlainSourceClass, PlainDestinationClass>(source);

            Assert.That(destination.Id, Is.EqualTo(source.Id));
            Assert.That(destination.Name, Is.EqualTo(source.Name));
            Assert.That(destination.DestFieldOnly, Is.Null.Or.Empty);
        }
예제 #3
0
        public void CollectionTest()
        {
            var sourceItem = new PlainSourceClass {
                Id = 1, Name = "Test", SourceFieldOnly = "source"
            };
            var source = new CollectionSourceClass {
                Items = new [] { sourceItem }
            };
            var destination = _mapper.Map <CollectionSourceClass, CollectionDestinationClass>(source);

            Assert.That(destination.Items, Is.Not.Null);
            Assert.That(destination.Items.Count(), Is.EqualTo(source.Items.Count()));
            var destinationItem = destination.Items.First();

            Assert.That(destinationItem.Id, Is.EqualTo(sourceItem.Id));
            Assert.That(destinationItem.Name, Is.EqualTo(sourceItem.Name));
        }