コード例 #1
0
        public void MappingValue()
        {
            var mapper = new AnimalAnimalModelMapper();

            var source = new Animal { Id = 1, Name = "Test" };

            var expected = new AnimalModel { Id = 1, Name = "Test" };

            var candidate = mapper.Map(source);

            this.Check(expected, candidate);
        }
コード例 #2
0
        public void MapCreatesDestination()
        {
            var locator = new Mock<IServiceLocator>(MockBehavior.Strict);
            var engine = new SimpleMappingEngine(locator.Object);

            engine.RegisterMap(new AnimalAnimalModelMapper());

            var source = new Animal { Id = 1, Name = "Test" };
            var expected = new AnimalModel { Id = 1, Name = "Test" };            

            var candidate = engine.Map<Animal, AnimalModel>(source);

            this.Check(expected, candidate);
        }
コード例 #3
0
 public override void Map(Animal source, System.Xml.Linq.XElement destination)
 {
     destination.Add(
         this.XElement("Id2", source.Id),
         this.XElement("Name2", source.Name));
 }
コード例 #4
0
 public override void Map(XPathProcessor source, Animal destination)
 {
     destination.Id = source.ToInt("Id2");
     destination.Name = source.ToString("Name2");
 }