public void InitializeTest() { GenericIdentity identity = new GenericIdentity("jsucupira"); string[] roles = { SecurityGroups.ADMINISTRATOR }; GenericPrincipal principal = new GenericPrincipal(identity, roles); Thread.CurrentPrincipal = principal; MefLoader.Initialize(); IStoreRepository repository = MefBase.Resolve <IStoreRepository>(); StoreSelector = MefBase.Resolve <IStoreSelector>(); StoreUpdator = MefBase.Resolve <IStoreUpdator>(); SamplerOptions samplerOptions = new SamplerOptions(); samplerOptions.PropertyDefaults.Add(new PropertiesSettings { PropertyValue = "*****@*****.**", PropertyName = nameof(Store.ManagerEmail) }, SamplerOptions.Options.DefaultValue); samplerOptions.PropertyDefaults.Add(new PropertiesSettings { PropertyValue = "http://www.test.com/", PropertyName = nameof(Store.WebSiteUrl) }, SamplerOptions.Options.DefaultValue); samplerOptions.PropertyOptions.Add(nameof(Store.Description), SamplerOptions.Options.Paragraph); samplerOptions.PropertyOptions.Add(nameof(Store.Name), SamplerOptions.Options.OneWord); samplerOptions.PropertyOptions.Add(nameof(Store.ManagerName), SamplerOptions.Options.OneWord); List <Store> stores = SamplerServices <Store> .CreateSampleData(ACTIVE_STORES - 1, samplerOptions); stores.ForEach(t => t.Activate()); //Creating active classes stores.ForEach(t => repository.Create(t)); //Creating non active classes SamplerServices <Store> .CreateSampleData(NON_ACTIVE_STORES, samplerOptions).ForEach(t => repository.Create(t)); samplerOptions.PropertyDefaults.Add(new PropertiesSettings { PropertyName = nameof(Store.Id), PropertyValue = DefaultStoreId.ToString() }, SamplerOptions.Options.DefaultValue); List <Store> defaultStore = SamplerServices <Store> .CreateSampleData(1, samplerOptions); defaultStore.ForEach(t => t.Activate()); defaultStore.ForEach(t => repository.Create(t)); }
public void InitializeTest() { GenericIdentity identity = new GenericIdentity("jsucupira"); string[] roles = { SecurityGroups.ADMINISTRATOR }; GenericPrincipal principal = new GenericPrincipal(identity, roles); Thread.CurrentPrincipal = principal; MefLoader.Initialize(); IStoreRepository repository = MefBase.Resolve<IStoreRepository>(); StoreSelector = MefBase.Resolve<IStoreSelector>(); StoreUpdator = MefBase.Resolve<IStoreUpdator>(); SamplerOptions samplerOptions = new SamplerOptions(); samplerOptions.PropertyDefaults.Add(new PropertiesSettings { PropertyValue = "*****@*****.**", PropertyName = nameof(Store.ManagerEmail) }, SamplerOptions.Options.DefaultValue); samplerOptions.PropertyDefaults.Add(new PropertiesSettings { PropertyValue = "http://www.test.com/", PropertyName = nameof(Store.WebSiteUrl) }, SamplerOptions.Options.DefaultValue); samplerOptions.PropertyOptions.Add(nameof(Store.Description), SamplerOptions.Options.Paragraph); samplerOptions.PropertyOptions.Add(nameof(Store.Name), SamplerOptions.Options.OneWord); samplerOptions.PropertyOptions.Add(nameof(Store.ManagerName), SamplerOptions.Options.OneWord); List<Store> stores = SamplerServices<Store>.CreateSampleData(ACTIVE_STORES - 1, samplerOptions); stores.ForEach(t => t.Activate()); //Creating active classes stores.ForEach(t => repository.Create(t)); //Creating non active classes SamplerServices<Store>.CreateSampleData(NON_ACTIVE_STORES, samplerOptions).ForEach(t => repository.Create(t)); samplerOptions.PropertyDefaults.Add(new PropertiesSettings { PropertyName = nameof(Store.Id), PropertyValue = DefaultStoreId.ToString() }, SamplerOptions.Options.DefaultValue); List<Store> defaultStore = SamplerServices<Store>.CreateSampleData(1, samplerOptions); defaultStore.ForEach(t => t.Activate()); defaultStore.ForEach(t => repository.Create(t)); }
public TypeBasedPersistance(IStoreSelector storeSelector, IIdGenerator idGenerator = null) { _idGenerator = idGenerator ?? new GuidIdGenerator(); _storeSelector = storeSelector; }
/// <summary> /// Save the store mappings for an entity /// </summary> /// <typeparam name="T">Entity type</typeparam> /// <param name="entity">The entity</param> /// <param name="model">Model representation of store selection</param> protected virtual void SaveStoreMappings <T>(T entity, IStoreSelector model) where T : BaseEntity, IStoreMappingSupported { entity.LimitedToStores = model.LimitedToStores; Services.Resolve <IStoreMappingService>().SaveStoreMappings(entity, model.SelectedStoreIds); }