public void Test1() { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); IPropFactory propFactory_V1 = ourHelper.GetNewPropFactory_V1(); PropModel pm = new PropModel ( className: "CreateAtRunTimeModel", namespaceName: "PropBagLib.Tests", deriveFrom: DeriveFromClassModeEnum.PropBag, targetType: null, propFactory: propFactory_V1, propFactoryType: null, propModelCache: null, typeSafetyMode: PropBagTypeSafetyMode.AllPropsMustBeRegistered, deferMethodRefResolution: true, requireExplicitInitialValue: true); PropItemModel pi = new PropItemModel(typeof(string), "PropString", PropStorageStrategyEnum.Internal, propKind: PropKindEnum.Prop, initialValueField: new PropInitialValueField("Initial Value")); pm.Add(pi.PropertyName, pi); ViewModelFactoryInterface viewModelFactory = ourHelper.ViewModelFactory; viewModelFactory.PropModelCache.Add(pm); mod1 = new CreateAtRunTimeModel(pm, viewModelFactory); Assert.That(mod1, Is.Not.EqualTo(null), "Expected the CreateAtRunTimeModel to have been created."); Assert.That(mod1.PropertyExists("PropString"), Is.True, "Expected the property with name = 'PropString' to have been create."); }
static public PerformanceModel Create(PropBagTypeSafetyMode safetyMode, ViewModelFactoryInterface viewModelFactory) { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); IPropFactory propFactory_V1 = ourHelper.GetNewPropFactory_V1(); PropModelType propModel = new PropModel ( "PerformanceModel", "PropBagLib.Tests", DeriveFromClassModeEnum.Custom, typeof(PerformanceModel), propFactory_V1, propFactoryType: null, propModelCache: null, typeSafetyMode: safetyMode, deferMethodRefResolution: true, requireExplicitInitialValue: true ); long generationId = viewModelFactory.PropModelCache.Add(propModel); PerformanceModel pmViewModel = new PerformanceModel(propModel, viewModelFactory); pmViewModel.AddPropNoStore <int>("PropIntNoStore"); pmViewModel.AddPropNoStore <string>("PropStringNoStore"); pmViewModel.AddProp <int>("PropInt"); pmViewModel.AddProp <string>("PropString"); pmViewModel.FixProps(); return(pmViewModel); }
public void Z_BindParent() { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); IPropBagMapperService autoMapperService = ourHelper.GetAutoMapperSetup_V1(); IPropFactory propFactory_V1 = ourHelper.GetNewPropFactory_V1(); ICreateWrapperTypes wrapperTypeCreator = ourHelper.GetWrapperTypeCreator_V1(); ViewModelFactoryInterface viewModelFactory = ourHelper.ViewModelFactory; //viewModelFactory.PropModelCache.Add(propModel5); _propModelCache = viewModelFactory.PropModelCache; Assert.That(ourHelper.StoreAccessCreator.AccessCounter == 0, "The Provider of PropStoreAccessServices has not had its Access Counter reset."); List <DestinationModel1> destinationList = new List <DestinationModel1>(); PropModelHelpers pmHelpers = new PropModelHelpers(); // Set up Child VM (Using Model 5) PropModelType propModel5 = pmHelpers.GetPropModelForModel5Dest(propFactory_V1, _propModelCache); DestinationModel5 testChildVM = new DestinationModel5(pm: propModel5, viewModelFactory: viewModelFactory, autoMapperService: autoMapperService, propFactory: propFactory_V1, fullClassName: "PropBagLib.Tests.PerformanceDb.DestinationModel5"); Business b = new Business(); testChildVM.SetIt(b, "Business"); testChildVM.RegisterBinding <Business>("Business", "../Business"); //List<Person> personList = b.Get().ToList(); //ObservableCollection<Person> personList2 = new ObservableCollection<Person>(personList); //testChildVM.SetIt(personList2, "PersonCollection"); // Set up MainVM (Using Model 6) PropModelType propModel6 = pmHelpers.GetPropModelForModel6Dest(propFactory_V1, _propModelCache); DestinationModel6 testMainVM = new DestinationModel6(propModel6, viewModelFactory, autoMapperService, propFactory_V1, null); Business b2 = new Business(); testMainVM.SetIt(b2, "Business"); testMainVM.SetIt <DestinationModel5>(testChildVM, "ChildVM"); testMainVM.RegisterBinding <Business>("Business", "./ChildVM/Business"); b2 = new Business(); testMainVM.SetIt(b2, "Business"); }
public void CanMapObservableCollection_AProxy() { _ourHelper = new AutoMapperHelpers(); _propFactory_V1 = _ourHelper.GetNewPropFactory_V1(); _amp = _ourHelper.GetAutoMapperSetup_V1(); _propModelCache = _ourHelper.GetPropModelCache_V1(); _pmHelpers = new PropModelHelpers(); string configPackageName = "Emit_Proxy"; ObservableCollTestObject oTester = new ObservableCollTestObject(); oTester.CanMapObservableCollection(configPackageName, _ourHelper, _propFactory_V1, _propModelCache, _amp, _pmHelpers, NUMBER_OF_PEOPLE); //oTester.DoCleanup(); }
public void MapOcAndCleanUp() { GC.WaitForPendingFinalizers(); GC.WaitForFullGCComplete(); _ourHelper = new AutoMapperHelpers(); ICreateWrapperTypes wrapperTypeCreator = _ourHelper.GetWrapperTypeCreator_V1(); _propFactory_V1 = _ourHelper.GetNewPropFactory_V1(); _propModelCache = _ourHelper.GetPropModelCache_V1(); _amp = _ourHelper.GetAutoMapperSetup_V1(); _pmHelpers = new PropModelHelpers(); string configPackageName = "Extra_Members"; ObservableCollTestObject oTester = new ObservableCollTestObject(); oTester.CanMapObservableCollection(configPackageName, _ourHelper, _propFactory_V1, _propModelCache, _amp, _pmHelpers, NUMBER_OF_PEOPLE); oTester.DoCleanup(); oTester = null; //Thread.Sleep(new TimeSpan(0, 0, 1)); //for (int tp = 0; tp < 5; tp++) //{ // // Yield for 1 seconds. // Thread.Sleep(new TimeSpan(0, 0, 1)); // GC.WaitForPendingFinalizers(); // GC.WaitForFullGCComplete(); //} GC.WaitForPendingFinalizers(); GC.WaitForFullGCComplete(); }
public void ReadIntoMappedArray() { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); IPropFactory propFactory_V1 = ourHelper.GetNewPropFactory_V1(); string fullClassName = "PropBagLib.Tests.PerformanceDb.DestinationModel1"; List <DestinationModel1> destinationList = new List <DestinationModel1>(); Assert.That(ourHelper.StoreAccessCreator.AccessCounter == 0, "The Provider of PropStoreAccessServices has not had its Access Counter reset."); Business b = new Business(); List <Person> personList = b.Get(1000).ToList(); foreach (Person p in personList) { // TODO: AAA DestinationModel1 dest = new DestinationModel1(PropBagTypeSafetyMode.Tight, ourHelper.StoreAccessCreator, propFactory_V1, fullClassName); dest.SetIt <int>(p.Id, "Id"); dest.SetIt <string>(p.FirstName, "FirstName"); dest.SetIt <string>(p.LastName, "LastName"); dest.SetIt <string>(p.CityOfResidence, "CityOfResidence"); dest.SetIt <Profession>(p.Profession, "Profession"); destinationList.Add(dest); } Assert.That(destinationList.Count == 1000, $"The PersonList contains {destinationList.Count}, it should contain {NUMBER_OF_PEOPLE}."); int totalNumberOfGets = ourHelper.StoreAccessCreator.AccessCounter; Assert.That(totalNumberOfGets == NUMBER_OF_PEOPLE * 5, $"Total # of SetIt access operations is wrong: it should be {NUMBER_OF_PEOPLE * 5}, but instead it is {totalNumberOfGets}."); PropBag test = (PropBag)destinationList[0]; int howManyDoSetDelegatesGotCreated = test.NumOfDoSetDelegatesInCache; }