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