public void CanGetMapperForMod3ToDestination_Proxy() { IPropFactory propFactory = _propFactory_V1; ViewModelFactoryInterface viewModelFactory = _viewModelFactory; PropModel propModel = GetPropModelForModel3Dest(propFactory); viewModelFactory.PropModelCache.Add(propModel); Type typeToWrap = typeof(PropBag); string configPackageName = "Emit_Proxy"; IMapperRequest mapperRequest = new MapperRequest(typeof(MyModel3), propModel, configPackageName); Type et = _wrapperTypeCreator_V1.GetWrapperType(propModel, typeToWrap); propModel.NewEmittedType = et; IPropBagMapperRequestKeyGen mapperKey = _amp.SubmitPropBagMapperRequest(mapperRequest.PropModel, mapperRequest.SourceType, mapperRequest.ConfigPackageName); // Get the AutoMapper mapping function associated with the mapper request already submitted. IPropBagMapperGen genMapper = _amp.GetPropBagMapper(mapperKey); //IMapper genMapper = _amp.GetRawAutoMapper(mapperKey); Assert.That(mapperKey, Is.Not.Null, "mapperRequest should be non-null."); //IPropBagMapper<MyModel3, DestinationModel3> mapper = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest); Assert.That(genMapper, Is.Not.Null, "mapper should be non-null"); MyModel4 dp = new MyModel4 { MyString = "This is a good thing." }; MyModel3 testSource = new MyModel3 { Amount = 11, Size = 22.22, ProductId = Guid.Empty, Deep = dp }; var testDest = genMapper.MapToDestination(testSource); //IPropBagMapperKey<MyModel3, DestinationModel3> mapperRequest2 = // _amp.SubmitMapperRequest<MyModel3, DestinationModel3> // ( // propModel: propModel, // typeToWrap: typeToWrap, // configPackageName: configPackageName // ); //IPropBagMapper<MyModel3, DestinationModel3> mapper2 = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest2); IPropBagMapperRequestKeyGen mapperKey2 = _amp.SubmitPropBagMapperRequest(mapperRequest.PropModel, mapperRequest.SourceType, mapperRequest.ConfigPackageName); // Get the AutoMapper mapping function associated with the mapper request already submitted. IPropBagMapperGen genMapper2 = _amp.GetPropBagMapper(mapperKey2); var testDest2 = genMapper2.MapToDestination(testSource); }
public void CanGetMapperForMod3ToDestination_Extra() { IPropFactory propFactory = _propFactory_V1; ViewModelFactoryInterface viewModelFactory = _viewModelFactory; PropModel propModel = GetPropModelForModel3Dest(propFactory); viewModelFactory.PropModelCache.Add(propModel); Type typeToWrap = typeof(DestinationModel3); // typeof(PropBag); string configPackageName = "Extra_Members"; // "Emit_Proxy"; IMapperRequest mr = new MapperRequest(typeof(MyModel3), propModel, configPackageName); //IMapper rawAutoMapper = AutoMapperHelpers.GetAutoMapper<MyModel3, DestinationModel3> // ( // mr, // _amp, // out IPropBagMapperKey<MyModel3, DestinationModel3> propBagMapperKey // ); //IPropBagMapper<MyModel3, DestinationModel3> cookedAutoMapper = new SimplePropBagMapper<MyModel3, DestinationModel3> // ( // propBagMapperKey, // rawAutoMapper, // viewModelFactory, // _amp // ); IPropBagMapper <MyModel3, DestinationModel3> propBagMapper = AutoMapperHelpers.GetAutoMapper <MyModel3, DestinationModel3> ( mr, _amp, out IPropBagMapperRequestKey <MyModel3, DestinationModel3> propBagMapperKey ); //IPropBagMapperKey<MyModel3, DestinationModel3> mapperRequest = // _amp.SubmitMapperRequest<MyModel3, DestinationModel3> // ( // propModel: propModel, // viewModelFactory: viewModelFactory, // typeToWrap: typeToWrap, // configPackageName: configPackageName // ); Assert.That(propBagMapperKey, Is.Not.Null, "mapperRequest should be non-null."); //IPropBagMapper<MyModel3, DestinationModel3> mapper = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest); Assert.That(propBagMapper, Is.Not.Null, "mapper should be non-null"); MyModel4 dp = new MyModel4 { MyString = "This is a good thing." }; MyModel3 testSource = new MyModel3 { Amount = 11, Size = 22.22, ProductId = Guid.Empty, Deep = dp }; DestinationModel3 testDest = propBagMapper.MapToDestination(testSource); //IPropBagMapperKey<MyModel3, DestinationModel3> mapperRequest2 = // _amp.SubmitMapperRequest<MyModel3, DestinationModel3> // ( // propModel: propModel, // viewModelFactory: viewModelFactory, // typeToWrap: typeToWrap, // configPackageName: configPackageName // ); //IPropBagMapper<MyModel3, DestinationModel3> mapper2 = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest2); IPropBagMapper <MyModel3, DestinationModel3> propBagMapper2 = AutoMapperHelpers.GetAutoMapper <MyModel3, DestinationModel3> ( mr, _amp, out IPropBagMapperRequestKey <MyModel3, DestinationModel3> propBagMapperKey2 ); //IPropBagMapper<MyModel3, DestinationModel3> cookedAutoMapper2 = new SimplePropBagMapper<MyModel3, DestinationModel3> // ( // propBagMapperKey, // rawAutoMapper, // viewModelFactory, // _amp // ); DestinationModel3 testDest2 = propBagMapper2.MapToDestination(testSource); }