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 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);

			}

		}