public override void DefService()
 {
     ServManager.AddService(ServiceNameEnum.Store);
     ServManager.AddService(ServiceNameEnum.AppConfig);
     ServManager.AddService(ServiceNameEnum.Catalog);
     ServManager.AddService(ServiceNameEnum.Order);
 }
示例#2
0
 private void Awake()
 {
     if (!Instance)
     {
         Instance = this;
     }
 }
        public void Can_create_catalogviewmodel_in_wizardmode()
        {
            var vmFactory = new TestCatalogViewModelFactory <ICatalogOverviewStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var repositoryFactory =
                new DSRepositoryFactory <ICatalogRepository, DSCatalogClient, CatalogEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.Catalog));

            //create item using entity factory
            var entityFactory = new CatalogEntityFactory();
            var item          = entityFactory.CreateEntity <Catalog>();

            var createViewModel   = new CreateCatalogViewModel(vmFactory, item);
            var overviewViewModel = createViewModel.AllRegisteredSteps[0] as ViewModelDetailAndWizardBase <Catalog>;

            overviewViewModel.InitializeForOpen();

            //check the default values in stepViewModel
            Assert.False(createViewModel.AllRegisteredSteps[0].IsValid);

            // step 1
            //fill the properties for the first step
            overviewViewModel.InnerItem.CatalogId = "TestCatalog";
            overviewViewModel.InnerItem.Name      = "TestName";
            overviewViewModel.InnerItem.CatalogLanguages.Add(new CatalogLanguage()
            {
                Language  = "ru-ru",
                CatalogId = overviewViewModel.InnerItem.CatalogId
            });
            overviewViewModel.InnerItem.DefaultLanguage = "ru-ru";

            Assert.True(createViewModel.AllRegisteredSteps[0].IsValid);

            // final actions: save
            createViewModel.PrepareAndSave();

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb = repository.Catalogs.Where(s => s.CatalogId == item.CatalogId).OfType <Catalog>().Expand(x => x.CatalogLanguages).SingleOrDefault();

                Assert.NotNull(itemFromDb);
                Assert.True(itemFromDb.Name == "TestName");
                Assert.True(itemFromDb.DefaultLanguage == "ru-ru");
                Assert.True(itemFromDb.CatalogLanguages.Any(x => x.Language == "ru-ru"));
            }
        }
示例#4
0
        public void Can_create_contentpublishingitemviewmodel_in_wizardmode()
        {
            var overviewVmFactory   = new TestDynamicContentViewModelFactory <IContentPublishingOverviewStepViewModel>(ServManager.GetUri(ServiceNameEnum.DynamicContent));
            var placeVmFactory      = new TestDynamicContentViewModelFactory <IContentPublishingContentPlacesStepViewModel>(ServManager.GetUri(ServiceNameEnum.DynamicContent));
            var contentVmFactory    = new TestDynamicContentViewModelFactory <IContentPublishingDynamicContentStepViewModel>(ServManager.GetUri(ServiceNameEnum.DynamicContent));
            var conditionsVmFactory = new TestDynamicContentViewModelFactory <IContentPublishingConditionsStepViewModel>(ServManager.GetUri(ServiceNameEnum.DynamicContent));
            var repositoryFactory   =
                new DSRepositoryFactory <IDynamicContentRepository, DSDynamicContentClient, DynamicContentEntityFactory>(ServManager.GetUri(ServiceNameEnum.DynamicContent));

            //creating additional objects
            DynamicContentPlace[] contentPlaces;
            DynamicContentItem[]  contentItems;
            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                contentItems  = TestContentItemsBuilder.BuildsContentItems().GetItems().ToArray();
                contentPlaces = TestContentPlacesBuilder.BuildContentPlaces().GetPlaces().ToArray();

                RepositoryHelper.AddItemToRepository(repository, contentItems.AsEnumerable());
                RepositoryHelper.AddItemToRepository(repository, contentPlaces.AsEnumerable());
            }

            var entityFactory = new DynamicContentEntityFactory();
            var item          = entityFactory.CreateEntity <DynamicContentPublishingGroup>();

            //create viewmodel in wizardmode
            var createContentPublishngItemViewModel = new CreateContentPublishingItemViewModel(overviewVmFactory, placeVmFactory, contentVmFactory, conditionsVmFactory, item);

            Assert.NotNull(createContentPublishngItemViewModel);
            Assert.False(createContentPublishngItemViewModel.AllRegisteredSteps[0].IsValid);
            Assert.False(createContentPublishngItemViewModel.AllRegisteredSteps[1].IsValid);
            Assert.False(createContentPublishngItemViewModel.AllRegisteredSteps[2].IsValid);
            Assert.True(createContentPublishngItemViewModel.AllRegisteredSteps[3].IsValid);

            //fill the first step
            var firstStep = createContentPublishngItemViewModel.AllRegisteredSteps[0] as ContentPublishingOverviewStepViewModel;

            Assert.NotNull(firstStep);
            firstStep.InitializeForOpen();
            firstStep.InnerItem.Name        = "NewTestName";
            firstStep.InnerItem.Description = "NewTestDescription";
            firstStep.InnerItem.Priority    = 0;

            Assert.True(firstStep.IsValid);

            //fill the 2 step
            var secondStep =
                createContentPublishngItemViewModel.AllRegisteredSteps[1] as ContentPublishingContentPlacesStepViewModel;

            Assert.NotNull(secondStep);
            secondStep.InitializeForOpen();


            secondStep.InnerItemContentPlaces.Add(contentPlaces[0]);

            Assert.True(secondStep.IsValid);


            //fill the 3 step
            var thirdStep =
                createContentPublishngItemViewModel.AllRegisteredSteps[2] as
                ContentPublishingDynamicContentStepViewModel;

            Assert.NotNull(thirdStep);
            thirdStep.InitializeForOpen();
            thirdStep.InnerItemDynamicContent.Add(contentItems[0]);

            Assert.True(thirdStep.IsValid);

            //fill the 4 step
            var fourthStep =
                createContentPublishngItemViewModel.AllRegisteredSteps[3] as ContentPublishingConditionsStepViewModel;

            Assert.NotNull(fourthStep);
            fourthStep.InitializeForOpen();

            var expression = TestContentPublishingExpressionBuilder.BuildContentPublishingExpressionBuilder(
                fourthStep.ExpressionElementBlock.Children[0])
                             .AddCartTotalElement(fourthStep.ExpressionElementBlock.ExpressionViewModel)
                             .AddConditionAddOrBlock(fourthStep.ExpressionElementBlock.ExpressionViewModel).GetChild();

            fourthStep.ExpressionElementBlock.Children[0] = expression;

            Assert.True(fourthStep.IsValid);

            createContentPublishngItemViewModel.PrepareAndSave();

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb =
                    repository.PublishingGroups.Where(
                        s => s.DynamicContentPublishingGroupId == firstStep.InnerItem.DynamicContentPublishingGroupId)
                    .Expand(cpg => cpg.ContentItems).Expand(cpg => cpg.ContentPlaces)
                    .SingleOrDefault();

                Assert.True(itemFromDb.Name == "NewTestName");
                Assert.True(itemFromDb.Description == "NewTestDescription");
                Assert.NotNull(itemFromDb.ConditionExpression);
                Assert.NotNull(itemFromDb.PredicateVisualTreeSerialized);
            }
        }
示例#5
0
 public override void DefService()
 {
     ServManager.AddService(ServiceNameEnum.DynamicContent);
 }
示例#6
0
        public void Can_create_contentpublishingviewmodel_in_editmode_hardmode()
        {
            var repositoryFactory =
                new DSRepositoryFactory <IDynamicContentRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var storeRepositoryFactory =
                new DSRepositoryFactory <IStoreRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var countryRepositoryFactory =
                new DSRepositoryFactory <ICountryRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));
            var appConfigRepositoryFactory =
                new DSRepositoryFactory <IAppConfigRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var searchCategoryVmFactory =
                new TestDynamicContentViewModelFactory <ISearchCategoryViewModel>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var navigationManager = new TestNavigationManager();

            DynamicContentPlace[] contentPlaces;
            DynamicContentItem[]  contentItems;
            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                contentPlaces = TestContentPlacesBuilder.BuildContentPlaces().GetPlaces().ToArray();
                contentItems  = TestContentItemsBuilder.BuildsContentItems().GetItems().ToArray();

                RepositoryHelper.AddItemToRepository(repository, contentItems.AsEnumerable());
                RepositoryHelper.AddItemToRepository(repository, contentPlaces.AsEnumerable());
            }

            //create fake innerItem
            var entityFactory = new DynamicContentEntityFactory();

            var item =
                TestContentPublishingBuilder.BuildDynamicContentPublishingGroup()
                .WithContentItems(contentItems.Take(1).ToArray())
                .WithContentPlaces(contentPlaces.Take(1).ToArray())
                .GetContentPublishingGroup();

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                RepositoryHelper.AddItemToRepository(repository, item);
            }

            var detailViewModel = new ContentPublishingItemViewModel(appConfigRepositoryFactory, countryRepositoryFactory, searchCategoryVmFactory, repositoryFactory, entityFactory, storeRepositoryFactory, navigationManager, item);

            Assert.NotNull(detailViewModel);
            detailViewModel.InitializeForOpen();

            detailViewModel.InnerItem.Name = "EditName";

            //edit 2 step
            detailViewModel.InnerItemContentPlaces.Add(contentPlaces[1]);
            detailViewModel.InnerItemContentPlaces.Remove(contentPlaces[1]);
            detailViewModel.InnerItemContentPlaces.Add(contentPlaces[1]);
            detailViewModel.InnerItemContentPlaces.Remove(contentPlaces[1]);
            detailViewModel.InnerItemContentPlaces.Add(contentPlaces[1]);

            //edit 3 step
            detailViewModel.InnerItemDynamicContent.Add(contentItems[2]);
            detailViewModel.InnerItemDynamicContent.Remove(contentItems[2]);
            detailViewModel.InnerItemDynamicContent.Add(contentItems[2]);
            detailViewModel.InnerItemDynamicContent.Remove(contentItems[2]);


            //edit 4 step
            var expressionViewModel = detailViewModel.ExpressionElementBlock.ExpressionViewModel;

            detailViewModel.ExpressionElementBlock.Children[0] =
                TestContentPublishingExpressionBuilder.BuildContentPublishingExpressionBuilder(
                    detailViewModel.ExpressionElementBlock.Children[0])
                .AddCartTotalElement(expressionViewModel).AddConditionAddOrBlock(expressionViewModel).GetChild();

            Assert.True(detailViewModel.IsValid);
            detailViewModel.SaveWithoutUIChanges();


            //check the item from db
            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb =
                    repository.PublishingGroups.Where(
                        pg =>
                        pg.DynamicContentPublishingGroupId ==
                        detailViewModel.InnerItem.DynamicContentPublishingGroupId)
                    .Expand(pg => pg.ContentItems).Expand(pg => pg.ContentPlaces).SingleOrDefault();

                Assert.NotNull(itemFromDb);
                Assert.True(itemFromDb.ContentItems.Count == 1);
                Assert.True(itemFromDb.ContentPlaces.Count == 2);
                Assert.True(itemFromDb.Name == "EditName");
                Assert.NotNull(itemFromDb.ConditionExpression);
                Assert.NotNull(itemFromDb.PredicateVisualTreeSerialized);
            }
        }
示例#7
0
        public void Can_create_contentpublishingviewmodel_in_editmode_simpleacenarios()
        {
            var repositoryFactory =
                new DSRepositoryFactory <IDynamicContentRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var storeRepositoryFactory =
                new DSRepositoryFactory <IStoreRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var countryRepositoryFactory =
                new DSRepositoryFactory <ICountryRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var appConfigRepositoryFactory =
                new DSRepositoryFactory <IAppConfigRepository, DSDynamicContentClient, DynamicContentEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var searchCategoryVmFactory =
                new TestDynamicContentViewModelFactory <ISearchCategoryViewModel>(
                    ServManager.GetUri(ServiceNameEnum.DynamicContent));

            var navigationManager = new TestNavigationManager();

            DynamicContentPlace[] contentPlaces;
            DynamicContentItem[]  contentItems;
            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                contentPlaces = TestContentPlacesBuilder.BuildContentPlaces().GetPlaces().ToArray();
                contentItems  = TestContentItemsBuilder.BuildsContentItems().GetItems().ToArray();

                RepositoryHelper.AddItemToRepository(repository, contentPlaces.AsEnumerable());
                RepositoryHelper.AddItemToRepository(repository, contentItems.AsEnumerable());
            }

            //create fake innerItem
            var entityFactory = new DynamicContentEntityFactory();

            var item =
                TestContentPublishingBuilder.BuildDynamicContentPublishingGroup()
                .WithContentItems(contentItems)
                .WithContentPlaces(contentPlaces)
                .GetContentPublishingGroup();

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                RepositoryHelper.AddItemToRepository(repository, item);
            }

            var detailViewModel = new ContentPublishingItemViewModel(appConfigRepositoryFactory, countryRepositoryFactory, searchCategoryVmFactory, repositoryFactory, entityFactory, storeRepositoryFactory, navigationManager, item);

            Assert.NotNull(detailViewModel);
            detailViewModel.InitializeForOpen();



            //edit properties in detail viewmodel
            detailViewModel.InnerItem.Name        = string.Empty;
            detailViewModel.InnerItem.Description = "EditDescription";
            detailViewModel.InnerItem.Priority    = 23;

            detailViewModel.InnerItemDynamicContent.Clear();
            detailViewModel.InnerItemDynamicContent.Add(contentItems[1]);

            detailViewModel.InnerItemContentPlaces.Clear();
            detailViewModel.InnerItemContentPlaces.Add(contentPlaces[1]);

            detailViewModel.InnerItem.Name = "EditName";
            Assert.True(detailViewModel.IsValid);


            detailViewModel.SaveWithoutUIChanges();

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb =
                    repository.PublishingGroups.Where(
                        pg =>
                        pg.DynamicContentPublishingGroupId ==
                        detailViewModel.InnerItem.DynamicContentPublishingGroupId)
                    .Expand(pg => pg.ContentItems).Expand(pg => pg.ContentPlaces).SingleOrDefault();

                Assert.NotNull(itemFromDb);
                Assert.True(itemFromDb.ContentItems[0].DynamicContentItemId == contentItems[1].DynamicContentItemId);
                Assert.True(itemFromDb.ContentPlaces[0].DynamicContentPlaceId == contentPlaces[1].DynamicContentPlaceId);
                Assert.True(itemFromDb.Name == "EditName");
            }
        }
        public void Can_create_storeviewmodel_in_wizardmode()
        {
            var overviewVmFactory = new TestFulfillmentViewModelFactory <IStoreOverviewStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var navigationVmFactory = new TestFulfillmentViewModelFactory <IStoreNavigationStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var localizationVmFactory = new TestFulfillmentViewModelFactory <IStoreLocalizationStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var taxesVmFactory = new TestFulfillmentViewModelFactory <IStoreTaxesStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var paymentsVmFactory = new TestFulfillmentViewModelFactory <IStorePaymentsStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));


            var repositoryFactory =
                new DSRepositoryFactory <IStoreRepository, DSStoreClient, StoreEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.Store));

            //create item using entity factory
            var entityFactory = new StoreEntityFactory();
            var item          = entityFactory.CreateEntity <Store>();

            var createStoreViewModel = new CreateStoreViewModel(overviewVmFactory, localizationVmFactory, taxesVmFactory, paymentsVmFactory, navigationVmFactory, item);


            //check the default values in stepViewModel
            Assert.False(createStoreViewModel.AllRegisteredSteps[0].IsValid);
            Assert.False(createStoreViewModel.AllRegisteredSteps[1].IsValid);
            Assert.True(createStoreViewModel.AllRegisteredSteps[2].IsValid);
            Assert.True(createStoreViewModel.AllRegisteredSteps[3].IsValid);
            Assert.True(createStoreViewModel.AllRegisteredSteps[4].IsValid);

            //1 step
            //fill the properties in first step
            var overviewViewModel = createStoreViewModel.AllRegisteredSteps[0] as StoreViewModel;

            Assert.NotNull(overviewViewModel);
            overviewViewModel.InnerItem.Name    = "TestName";
            overviewViewModel.InnerItem.Catalog = "TestCatalog";
            overviewViewModel.InitializeForOpen();
            Assert.True(createStoreViewModel.AllRegisteredSteps[0].IsValid);


            //2 step
            //fill the properties in second step
            var localizationStep = createStoreViewModel.AllRegisteredSteps[1] as StoreViewModel;

            Assert.NotNull(localizationStep);
            localizationStep.InnerItem.Languages.Add(new StoreLanguage()
            {
                LanguageCode = "ru-ru",
                StoreId      = localizationStep.InnerItem.StoreId
            });
            localizationStep.InnerItem.DefaultLanguage = "ru-ru";

            localizationStep.InnerItem.Currencies.Add(new StoreCurrency()
            {
                CurrencyCode = "RUR",
                StoreId      = localizationStep.InnerItem.StoreId
            });
            localizationStep.InnerItem.DefaultCurrency = "RUR";

            Assert.True(createStoreViewModel.AllRegisteredSteps[1].IsValid);


            //3 step
            //fill the properties in third step
            var taxesStep = createStoreViewModel.AllRegisteredSteps[2] as StoreTaxesStepViewModel;

            Assert.NotNull(taxesStep);
            taxesStep.InitializeForOpen();

            taxesStep.AvailableTaxCodes[0].IsChecked         = true;
            taxesStep.AvailableTaxJurisdictions[0].IsChecked = true;

            Assert.True(taxesStep.IsValid);


            //4 step
            //fill the properties in 4 step
            var paymentsStep = createStoreViewModel.AllRegisteredSteps[3] as StorePaymentsStepViewModel;

            Assert.NotNull(paymentsStep);
            paymentsStep.InitializeForOpen();

            paymentsStep.AvailableStoreCardTypes[0].IsChecked = true;

            Assert.True(paymentsStep.IsValid);


            //5 step
            //fill the properties in 5 step
            var navigationStep = createStoreViewModel.AllRegisteredSteps[4] as StoreNavigationStepViewModel;

            Assert.NotNull(navigationStep);
            navigationStep.InitializeForOpen();

            navigationStep.SettingFilteredNavigation.LongTextValue = "TestnavigationText";
            Assert.True(navigationStep.IsValid);

            createStoreViewModel.PrepareAndSave();
            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb =
                    repository.Stores.Where(s => s.StoreId == item.StoreId).ExpandAll().SingleOrDefault();

                Assert.NotNull(itemFromDb);
                Assert.True(itemFromDb.Name == "TestName");
                Assert.True(itemFromDb.Catalog == "TestCatalog");
                Assert.True(itemFromDb.Languages.Any(x => x.LanguageCode == "ru-ru"));
                Assert.True(itemFromDb.Currencies.Any(x => x.CurrencyCode == "RUR"));
            }
        }
        public void create_storeviewmodel_in_detailmode_and_edit()
        {
            var overviewVmFactory = new TestFulfillmentViewModelFactory <IStoreOverviewStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var navigationVmFactory = new TestFulfillmentViewModelFactory <IStoreNavigationStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var localizationVmFactory = new TestFulfillmentViewModelFactory <IStoreLocalizationStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var taxesVmFactory = new TestFulfillmentViewModelFactory <IStoreTaxesStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var paymentsVmFactory = new TestFulfillmentViewModelFactory <IStorePaymentsStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var linkedStoresVmFactory = new TestFulfillmentViewModelFactory <IStoreLinkedStoresStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var settingVmFactory = new TestFulfillmentViewModelFactory <IStoreSettingStepViewModel>(
                ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Catalog),
                ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var entityFactory = new StoreEntityFactory();
            var item          = entityFactory.CreateEntity <Store>();

            var repositoryFactory =
                new DSRepositoryFactory <IStoreRepository, DSStoreClient, StoreEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.Store));

            var navigationManager = new TestNavigationManager();



            //fill the properties of InnerItem;
            item.Name    = "testName";
            item.Catalog = "testcatalog";
            item.Languages.Add(new StoreLanguage()
            {
                LanguageCode = "ru-ru", StoreId = item.StoreId
            });
            item.DefaultLanguage = "ru-ru";
            item.Currencies.Add(new StoreCurrency()
            {
                CurrencyCode = "RUR", StoreId = item.StoreId
            });
            item.DefaultCurrency = "RUR";

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                repository.Add(item);
                repository.UnitOfWork.Commit();
            }


            var detailStoreViewModel = new StoreViewModel(repositoryFactory, entityFactory, overviewVmFactory, localizationVmFactory, taxesVmFactory, paymentsVmFactory, navigationVmFactory, settingVmFactory, linkedStoresVmFactory, null, null,
                                                          navigationManager, item);

            Assert.NotNull(detailStoreViewModel);
            detailStoreViewModel.InitializeForOpen();


            //edit various properties
            detailStoreViewModel.InnerItem.Name    = "EditingName";
            detailStoreViewModel.InnerItem.Catalog = "EditedCatalog";


            detailStoreViewModel.InnerItem.Languages.Add(new StoreLanguage()
            {
                LanguageCode = "de-de",
                StoreId      = detailStoreViewModel.InnerItem.StoreId
            });
            detailStoreViewModel.InnerItem.DefaultLanguage = "de-de";

            detailStoreViewModel.InnerItem.Currencies.Add(new StoreCurrency()
            {
                CurrencyCode = "USD",
                StoreId      = detailStoreViewModel.InnerItem.StoreId
            });


            detailStoreViewModel.TaxesStepViewModel.AvailableTaxCodes[0].IsChecked         = true;
            detailStoreViewModel.TaxesStepViewModel.AvailableTaxCodes[1].IsChecked         = true;
            detailStoreViewModel.TaxesStepViewModel.AvailableTaxJurisdictions[0].IsChecked = true;

            detailStoreViewModel.PaymentsStepViewModel.AvailableStoreCardTypes[0].IsChecked = true;

            (detailStoreViewModel.NavigationStepViewModel as StoreNavigationStepViewModel).SettingFilteredNavigation
            .LongTextValue = "NewNavigationText";

            detailStoreViewModel.SaveWithoutUIChanges();


            Store storeFromDb = null;

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                storeFromDb =
                    repository.Stores.Where(s => s.StoreId == detailStoreViewModel.InnerItem.StoreId).SingleOrDefault();

                Assert.NotNull(storeFromDb);
                Assert.True(storeFromDb.Name == "EditingName");
            }


            //edit various properties

            var detailStoreViewModel2 = new StoreViewModel(repositoryFactory, entityFactory, overviewVmFactory, localizationVmFactory, taxesVmFactory, paymentsVmFactory, navigationVmFactory, settingVmFactory, linkedStoresVmFactory, null, null,
                                                           navigationManager, item);

            Assert.NotNull(detailStoreViewModel2);
            detailStoreViewModel2.InitializeForOpen();

            detailStoreViewModel.InnerItem.Name = "2 edit";
            detailStoreViewModel.TaxesStepViewModel.AvailableTaxCodes[0].IsChecked = false;
            detailStoreViewModel.TaxesStepViewModel.AvailableTaxCodes[1].IsChecked = false;

            detailStoreViewModel.InnerItem.Settings.Add(new StoreSetting()
            {
                Name           = "testSettings",
                ValueType      = "0",
                ShortTextValue = "ShortTextValue",
                StoreId        = detailStoreViewModel.InnerItem.StoreId
            });


            detailStoreViewModel.SaveWithoutUIChanges();


            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb =
                    repository.Stores.Where(s => s.StoreId == detailStoreViewModel.InnerItem.StoreId).Expand(s => s.Settings).SingleOrDefault();

                Assert.NotNull(itemFromDb);
                Assert.True(itemFromDb.Name == "2 edit");


                var setting = itemFromDb.Settings.SingleOrDefault(ss => ss.Name == "testSettings");
                Assert.NotNull(setting);
            }
        }
        public void Can_add_update_delete_item_property_values()
        {
            var catalogName    = "Test catalog";
            var catalogBuilder = CatalogBuilder.BuildCatalog(catalogName).WithCategory("category").WithProducts(1);
            var catalog        = catalogBuilder.GetCatalog() as Catalog;
            var item           = catalogBuilder.GetItems()[0];

            var property1 = new Property {
                Name = "bool", PropertyValueType = PropertyValueType.Boolean.GetHashCode()
            };
            var property2 = new Property {
                Name = "datetime", PropertyValueType = PropertyValueType.DateTime.GetHashCode()
            };
            var property3 = new Property {
                Name = "Decimal", PropertyValueType = PropertyValueType.Decimal.GetHashCode()
            };
            var property4 = new Property {
                Name = "int", PropertyValueType = PropertyValueType.Integer.GetHashCode()
            };
            var property5 = new Property {
                Name = "longstr", PropertyValueType = PropertyValueType.LongString.GetHashCode()
            };
            var property6 = new Property {
                Name = "shorttext", PropertyValueType = PropertyValueType.ShortString.GetHashCode()
            };

            var propertySet = catalog.PropertySets[0];

            propertySet.PropertySetProperties.Add(new PropertySetProperty {
                Property = property1
            });
            propertySet.PropertySetProperties.Add(new PropertySetProperty {
                Property = property2
            });
            propertySet.PropertySetProperties.Add(new PropertySetProperty {
                Property = property3
            });
            propertySet.PropertySetProperties.Add(new PropertySetProperty {
                Property = property4
            });
            propertySet.PropertySetProperties.Add(new PropertySetProperty {
                Property = property5
            });
            propertySet.PropertySetProperties.Add(new PropertySetProperty {
                Property = property6
            });
            propertySet.PropertySetProperties.ToList().ForEach(x =>
            {
                x.Property.IsRequired = true;
                x.Property.CatalogId  = catalogName;
            });

            var repositoryFactory = new DSRepositoryFactory <ICatalogRepository, DSCatalogClient, CatalogEntityFactory>(ServManager.GetUri(ServiceNameEnum.Catalog));

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                repository.Add(catalog);
                repository.Add(item);
                repository.UnitOfWork.Commit();
            }

            IRepositoryFactory <IPricelistRepository>           pricelistRepositoryFactory    = new DSRepositoryFactory <IPricelistRepository, DSCatalogClient, CatalogEntityFactory>(ServManager.GetUri(ServiceNameEnum.Catalog));
            IViewModelsFactory <IPropertyValueBaseViewModel>    propertyValueVmFactory        = new TestCatalogViewModelFactory <IPropertyValueBaseViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            IViewModelsFactory <IPriceViewModel>                priceVmFactory                = new TestCatalogViewModelFactory <IPriceViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            IViewModelsFactory <IItemAssetViewModel>            assetVmFactory                = new TestCatalogViewModelFactory <IItemAssetViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            IViewModelsFactory <IAssociationGroupEditViewModel> associationGroupEditVmFactory = new TestCatalogViewModelFactory <IAssociationGroupEditViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            IViewModelsFactory <IAssociationGroupViewModel>     associationGroupVmFactory     = new TestCatalogViewModelFactory <IAssociationGroupViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            IViewModelsFactory <IItemRelationViewModel>         itemRelationVmFactory         = new TestCatalogViewModelFactory <IItemRelationViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            IViewModelsFactory <IEditorialReviewViewModel>      reviewVmFactory               = new TestCatalogViewModelFactory <IEditorialReviewViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            IViewModelsFactory <ICategoryItemRelationViewModel> categoryVmFactory             = new TestCatalogViewModelFactory <ICategoryItemRelationViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            ICatalogEntityFactory  entityFactory = new CatalogEntityFactory();
            IAuthenticationContext authContext   = new TestAuthenticationContext();
            INavigationManager     navManager    = new TestNavigationManager();

            var itemViewModel = new ItemViewModel(null, null, repositoryFactory, pricelistRepositoryFactory, propertyValueVmFactory, priceVmFactory, assetVmFactory, associationGroupEditVmFactory, associationGroupVmFactory, itemRelationVmFactory, reviewVmFactory, categoryVmFactory, entityFactory, item, authContext, navManager);

            itemViewModel.InitializeForOpen();

            // property change should set IsModified to true
            itemViewModel.InnerItem.EndDate = DateTime.UtcNow;
            Assert.True(itemViewModel.IsModified);

            Assert.False(itemViewModel.PropertyValueEditCommand.CanExecute(null));
            Assert.True(itemViewModel.PropertyValueEditCommand.CanExecute(itemViewModel.PropertiesAndValues[0]));

            itemViewModel.CommonConfirmRequest.Raised += EditValueSetConfirmation;

            foreach (var propItem in itemViewModel.PropertiesAndValues)
            {
                itemViewModel.PropertyValueEditCommand.Execute(propItem);
            }

            itemViewModel.SaveChangesCommand.Execute(null);
            Thread.Sleep(1000);            // waiting for SaveChangesCommand to finish in background thread

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb = repository.Items.Expand(x => x.ItemPropertyValues).Single();

                Assert.True(itemFromDb.ItemPropertyValues.Count > 0);
                Assert.Equal(itemViewModel.PropertiesAndValues.Count, itemFromDb.ItemPropertyValues.Count);
            }

            // test if values are saved when updated in UI
            DecimalValue = 123123m;
            var valueToEdit =
                itemViewModel.PropertiesAndValues.First(x => x.Property.PropertyValueType == PropertyValueType.Decimal.GetHashCode());

            itemViewModel.PropertyValueEditCommand.Execute(valueToEdit);

            LongTextValue = "other long text";
            valueToEdit   = itemViewModel.PropertiesAndValues.First(x => x.Property.PropertyValueType == PropertyValueType.LongString.GetHashCode());
            itemViewModel.PropertyValueEditCommand.Execute(valueToEdit);

            itemViewModel.SaveChangesCommand.Execute(null);
            Thread.Sleep(1000);            // waiting for SaveChangesCommand to finish in background thread

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb = repository.Items.Expand(x => x.ItemPropertyValues).Single();

                Assert.Equal(DecimalValue, itemFromDb.ItemPropertyValues.First(x => x.ValueType == PropertyValueType.Decimal.GetHashCode()).DecimalValue);
                Assert.Equal(LongTextValue, itemFromDb.ItemPropertyValues.First(x => x.ValueType == PropertyValueType.LongString.GetHashCode()).LongTextValue);
            }

            // check if item can be saved without required property value
            var valueToDelete =
                itemViewModel.PropertiesAndValues.First(x => x.Property.PropertyValueType == PropertyValueType.Decimal.GetHashCode());

            itemViewModel.PropertyValueDeleteCommand.Execute(valueToDelete);

            itemViewModel.SaveChangesCommand.CanExecute(null);
            Thread.Sleep(1000);            // waiting for SaveChangesCommand to finish in background thread

            //Assert True as the last Save command execution failed as the validation failed
            Assert.True(itemViewModel.IsModified);
        }
        public void Can_create_categoryviewmodel_in_wizardmode()
        {
            var repositoryFactory =
                new DSRepositoryFactory <ICatalogRepository, DSCatalogClient, CatalogEntityFactory>(ServManager.GetUri(ServiceNameEnum.Catalog));

            const string catalogId      = "testcatalog";
            var          catalogBuilder = CatalogBuilder.BuildCatalog(catalogId);
            var          catalog        = catalogBuilder.GetCatalog() as Catalog;

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                repository.Add(catalog);
                repository.UnitOfWork.Commit();
            }

            var propertiesVmFactory = new TestCatalogViewModelFactory <ICategoryPropertiesStepViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));
            var overviewVmFactory   = new TestCatalogViewModelFactory <ICategoryOverviewStepViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));

            //create item using entity factory
            var entityFactory = new CatalogEntityFactory();
            var item          = entityFactory.CreateEntity <Category>();

            item.CatalogId = catalogId;
            item.Catalog   = catalog;

            var createViewModel   = new CreateCategoryViewModel(propertiesVmFactory, overviewVmFactory, item);
            var overviewViewModel = createViewModel.AllRegisteredSteps[0] as CategoryViewModel;

            overviewViewModel.InitializeForOpen();
            var propertyValuesViewModel = createViewModel.AllRegisteredSteps[1] as CategoryViewModel;

            propertyValuesViewModel.InitializeForOpen();

            //check the default values in stepViewModel
            Assert.False(createViewModel.AllRegisteredSteps[0].IsValid);
            Assert.True(createViewModel.AllRegisteredSteps[1].IsValid);

            // step 1
            //fill the properties for the first step
            overviewViewModel.InnerItem.Name = "TestName";
            overviewViewModel.InnerItem.Code = "TestCode";
            var propertySet = overviewViewModel.AvailableCategoryTypes.First();

            overviewViewModel.InnerItem.PropertySet   = propertySet;
            overviewViewModel.InnerItem.PropertySetId = propertySet.PropertySetId;

            Assert.True(createViewModel.AllRegisteredSteps[0].IsValid);

            // step 2
            //fill the values for the property values step
            propertyValuesViewModel.PropertiesAndValues[0].Value = new CategoryPropertyValue()
            {
                ShortTextValue = "short text",
                Name           = propertyValuesViewModel.PropertiesAndValues[0].Property.Name,
                ValueType      = propertyValuesViewModel.PropertiesAndValues[0].Property.PropertyValueType
            };
            propertyValuesViewModel.InnerItem.CategoryPropertyValues.Add((CategoryPropertyValue)propertyValuesViewModel.PropertiesAndValues[0].Value);

            Assert.True(createViewModel.AllRegisteredSteps[1].IsValid);

            // final actions: save
            propertyValuesViewModel.InnerItem.Catalog = null;
            createViewModel.PrepareAndSave();

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb = repository.Categories.Where(s => s.CategoryId == item.CategoryId).OfType <Category>().ExpandAll().SingleOrDefault();

                Assert.NotNull(itemFromDb);
                Assert.True(itemFromDb.Name == "TestName");
                Assert.True(itemFromDb.CategoryPropertyValues.Any(x => x.ShortTextValue == "short text"));
            }
        }
示例#12
0
        public void Can_create_cartpromotionviewmodel_in_wizardmode()
        {
            var overviewVmFactory   = new TestMarketingViewModelFactory <ICartPromotionOverviewStepViewModel>(ServManager.GetUri(ServiceNameEnum.Marketing), ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));
            var couponsVmFactory    = new TestMarketingViewModelFactory <ICartPromotionCouponStepViewModel>(ServManager.GetUri(ServiceNameEnum.Marketing), ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));
            var conditionsVmFactory = new TestMarketingViewModelFactory <ICartPromotionExpressionStepViewModel>(ServManager.GetUri(ServiceNameEnum.Marketing), ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.Store), ServManager.GetUri(ServiceNameEnum.Order), ServManager.GetUri(ServiceNameEnum.AppConfig));

            var repositoryFactory =
                new DSRepositoryFactory <IMarketingRepository, DSMarketingClient, MarketingEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.Marketing));


            var entityFactory = new MarketingEntityFactory();
            var item          = entityFactory.CreateEntity <CartPromotion>();

            //create viewmodel in wizardmode
            var createCartPromotionViewModel = new CreateCartPromotionViewModel(overviewVmFactory, conditionsVmFactory, couponsVmFactory, item);

            Assert.NotNull(createCartPromotionViewModel);
            Assert.False(createCartPromotionViewModel.AllRegisteredSteps[0].IsValid);
            Assert.False(createCartPromotionViewModel.AllRegisteredSteps[1].IsValid);
            Assert.True(createCartPromotionViewModel.AllRegisteredSteps[2].IsValid);

            //fill the first step
            var firstStep = createCartPromotionViewModel.AllRegisteredSteps[0] as CartPromotionOverviewStepViewModel;

            Assert.NotNull(firstStep);
            firstStep.InitializeForOpen();
            (firstStep.InnerItem as CartPromotion).StoreId = "TestStore";
            firstStep.InnerItem.StartDate   = DateTime.UtcNow;
            firstStep.InnerItem.Name        = "NewTestName";
            firstStep.InnerItem.Description = "NewTestDescription";
            firstStep.InnerItem.Priority    = 0;

            Assert.True(firstStep.IsValid);

            //fill the 2 step (expression builder)
            var secondStep =
                createCartPromotionViewModel.AllRegisteredSteps[1] as CartPromotionExpressionStepViewModel;

            Assert.NotNull(secondStep);
            secondStep.InitializeForOpen();
            var expression = CartPromotionExpressionBuilderHelper.BuildCartPromotionExpressionBuilder(
                (CartPromotionExpressionBlock)secondStep.ExpressionElementBlock)
                             .AddEveryoneEligibility(secondStep)
                             .AddNumItemsInCartElement(secondStep, false).GetChild();

            //.AddConditionAddOrBlock(secondStep).GetChild();

            secondStep.ExpressionElementBlock.Children[0] = expression;

            Assert.False(secondStep.IsValid);

            //fill the 3 step
            var thirdStep =
                createCartPromotionViewModel.AllRegisteredSteps[2] as
                CartPromotionCouponStepViewModel;

            Assert.NotNull(thirdStep);
            thirdStep.InitializeForOpen();
            thirdStep.HasCoupon = true;
            Assert.False(createCartPromotionViewModel.AllRegisteredSteps[2].IsValid);
            thirdStep.InnerItem.Coupon = new Coupon()
            {
                Code = "testCoupon"
            };
            Assert.True(createCartPromotionViewModel.AllRegisteredSteps[2].IsValid);

            Assert.True(thirdStep.IsValid);

            createCartPromotionViewModel.PrepareAndSave();

            using (var repository = repositoryFactory.GetRepositoryInstance())
            {
                var itemFromDb =
                    repository.Promotions.Where(
                        s => s.PromotionId == firstStep.InnerItem.PromotionId)
                    .Expand(cpg => cpg.Rewards)
                    .SingleOrDefault();

                Assert.True(itemFromDb.Name == "NewTestName");
                Assert.True(itemFromDb.Description == "NewTestDescription");
                Assert.NotNull(itemFromDb.PredicateSerialized);
                Assert.NotNull(itemFromDb.PredicateVisualTreeSerialized);
            }
        }
        public void Can_add_pricelist()
        {
            // create ViewModelsFactory ( it should be resolve all view models for the test)
            var overviewVmFactory = new TestCatalogViewModelFactory <IPriceListOverviewStepViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog), ServManager.GetUri(ServiceNameEnum.AppConfig));

            // create Item using EntityFactory
            var entityFactory = new CatalogEntityFactory();
            var item          = entityFactory.CreateEntity <Pricelist>();

            // create Wizard main class. Constructor of the class creates wizard steps with help vmFactory
            var createPriceListViewModel = new CreatePriceListViewModel(overviewVmFactory, item);

            // IsValid of wizard step should be false at the begin.
            Assert.False(createPriceListViewModel.AllRegisteredSteps[0].IsValid);

            var step = createPriceListViewModel.AllRegisteredSteps[0] as PriceListOverviewStepViewModel;

            step.InitializeForOpen();
            step.InnerItem.Name = "New test PriceList";
            Assert.Null(step.AllAvailableCurrencies);
            step.InnerItem.Currency = "USD";
            Assert.True(step.IsValid);
            createPriceListViewModel.PrepareAndSave();

            var priceListRepositoryFactory = new DSRepositoryFactory <IPricelistRepository, DSCatalogClient, CatalogEntityFactory>(ServManager.GetUri(ServiceNameEnum.Catalog));

            using (var repository = priceListRepositoryFactory.GetRepositoryInstance())
            {
                var checkItem = repository.Pricelists.Where(x => x.Name == "New test PriceList").FirstOrDefault();
                Assert.NotNull(checkItem);
            }
        }
        public void AddCurrencies()
        {
            // create Setting from factory
            var entityFactory = new AppConfigEntityFactory();
            var setting       = entityFactory.CreateEntity <Setting>();

            setting.Name             = "Currencies";
            setting.SettingValueType = "ShortText";
            setting.IsMultiValue     = true;
            setting.IsSystem         = true;

            // add currencies
            var id = setting.SettingId;

            setting.SettingValues.Add(new SettingValue()
            {
                ValueType = "ShortText", ShortTextValue = "USD", SettingId = id
            });
            setting.SettingValues.Add(new SettingValue()
            {
                ValueType = "ShortText", ShortTextValue = "EUR", SettingId = id
            });


            var appConfigFactory = new DSRepositoryFactory <IAppConfigRepository, DSAppConfigClient, AppConfigEntityFactory>(ServManager.GetUri(ServiceNameEnum.AppConfig));

            using (var appConfigRepository = appConfigFactory.GetRepositoryInstance())
            {
                appConfigRepository.Add(setting);
                appConfigRepository.UnitOfWork.Commit();
            }
        }
        public void Can_delete_pricelist()
        {
            #region Init parameters for PriceListHomeViewModel

            var priceListRepositoryFactory =
                new DSRepositoryFactory <IPricelistRepository, DSCatalogClient, CatalogEntityFactory>(
                    ServManager.GetUri(ServiceNameEnum.Catalog));
            IAuthenticationContext authenticationContext = new TestAuthenticationContext();
            var navigationManager = new TestNavigationManager();

            // create ViewModelsFactory ( it should be resolve all view models for the test)
            var itemVmFactory = new TestCatalogViewModelFactory <IPriceListViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog),
                                                                                      ServManager.GetUri(ServiceNameEnum.AppConfig));

            var wizardVmFactory = new TestCatalogViewModelFactory <ICreatePriceListViewModel>(ServManager.GetUri(ServiceNameEnum.Catalog),
                                                                                              ServManager.GetUri(ServiceNameEnum.AppConfig));

            // create Item using EntityFactory
            var entityFactory = new CatalogEntityFactory();

            #endregion

            #region Add price list to DB

            using (var repository = priceListRepositoryFactory.GetRepositoryInstance())
            {
                var pricelist = entityFactory.CreateEntity <Pricelist>();
                pricelist.Name     = "Test price (Can_delete_pricelist)";
                pricelist.Currency = "USD";

                repository.Add(pricelist);
                repository.UnitOfWork.Commit();
            }

            #endregion

            #region VM test

            var priceListHomeViewModel = new PriceListHomeViewModel(entityFactory, itemVmFactory, wizardVmFactory,
                                                                    priceListRepositoryFactory, authenticationContext,
                                                                    navigationManager, null);
            priceListHomeViewModel.InitializeForOpen();

            Thread.Sleep(3000);             // waiting for InitializeForOpen to finish in background thread

            priceListHomeViewModel.CommonConfirmRequest.Raised += DeletePriceListConfirmation;
            priceListHomeViewModel.ListItemsSource.MoveCurrentToFirst();
            var item          = priceListHomeViewModel.ListItemsSource.CurrentItem as VirtualListItem <IPriceListViewModel>;
            var itemsToDelete = new List <VirtualListItem <IPriceListViewModel> >()
            {
                item
            };
            priceListHomeViewModel.ItemDeleteCommand.Execute(itemsToDelete);

            Thread.Sleep(1000);            // waiting for ItemDeleteCommand to finish in background thread

            #endregion

            #region Check

            using (var repository = priceListRepositoryFactory.GetRepositoryInstance())
            {
                var checkItem = repository.Pricelists.Where(x => x.Name == "Test price (Can_delete_pricelist)").SingleOrDefault();
                Assert.Null(checkItem);
            }

            #endregion
        }