예제 #1
0
        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));
        }