예제 #1
0
        public void RegisterOneWayMapping_SimpleObjects()
        {
            _mapper.InitializeMap();

            var resourceObj = _builder.Build <ResourceClassSimple>();
            var domainObj   = new DomainClassSimple();

            _mapper.Map(resourceObj, domainObj, null);
            Assert.AreEqual(resourceObj.ExampleProperty, domainObj.ExampleProperty);
            Assert.IsNull(domainObj.RandomProperty);
        }
예제 #2
0
 private static void AssertAreEqual(ResourceClassSimple resource, DomainClassSimple domain)
 {
     if (resource == null)
     {
         Assert.IsNull(domain);
     }
     else
     {
         Assert.IsNotNull(domain);
         Assert.AreEqual(resource.ExampleProperty, domain.ExampleProperty);
     }
 }
예제 #3
0
        public void RegisterOneWayMap_Overlay_ConsumesMembers()
        {
            _mapper.ConvertUsing <string, int>(Convert.ToInt32);
            _mapper.ConvertUsing <int, string>(Convert.ToString);
            _mapper.RegisterOneWayMapping <ResourceClassNested, DomainClassSimple>(mapping =>
            {
                mapping.Ignore(to => to.RandomProperty);
                mapping.Overlay(to => to, from => from.Child);
            });
            _mapper.InitializeMap();

            var resourceObj = _builder.Build <ResourceClassNested>();
            var domainObj   = new DomainClassSimple();

            domainObj = _mapper.Map(resourceObj, domainObj, null);
            Assert.AreEqual(resourceObj.Child.ExampleProperty, domainObj.ExampleProperty);
        }