public void SearchItemsCommandTest() { var db = DataRepository.GetDataRepository; Assert.NotNull(db); var user = db.Load <UserDetail>("steph"); var userManager = new UserManager(db); UserManager.GetUserManager.LoginUser(user); var searchFilter = new SearchFilterOptions { User = UserManager.GetUserManager.CurrentUser(), SiteLocationEnabled = false, SearchFilterEnabled = true, SearchText = "Airway Kit", SelectEquipmentUnitsEnabled = false, SelectItemStatusValuesEnabled = false, SelectItemCategoryValuesEnabled = false }; Assert.NotNull(searchFilter, nameof(SearchFilterOptions)); var resultVM = new TestDetailsViewModel(); Assert.NotNull(resultVM, nameof(TestDetailsViewModel)); var onSelectionChangedCommand = new OnSelectionChangedCommand(resultVM); Assert.NotNull(onSelectionChangedCommand, nameof(OnSelectionChangedCommand)); var searchResultViewModel = new SearchResultViewModel(onSelectionChangedCommand); Assert.NotNull(searchResultViewModel, nameof(SearchResultViewModel)); var searchCmd = new SearchItemsCommand(QueryResultEntitySelector.ItemType, searchResultViewModel); Assert.NotNull(searchCmd, nameof(SearchItemsCommand)); Assert.IsTrue(searchCmd.CanExecute(searchFilter)); Assert.IsNull(resultVM.CurrentItem); // nothing selected to display details of Assert.That(searchResultViewModel.Items.Count, Is.EqualTo(0)); // no search results or empty search results searchCmd.Execute(searchFilter); searchCmd.WaitForSearchToComplete(); Assert.That(searchResultViewModel.Items.Count, Is.GreaterThan(0)); searchResultViewModel.SelectedItem = searchResultViewModel.Items.First(); Assert.NotNull(searchResultViewModel.SelectedItem); Assert.NotNull(resultVM.CurrentItem); Assert.AreNotEqual(Guid.Empty, resultVM.CurrentItem.id); Assert.NotNull(resultVM.CurrentItem.entityType); Assert.NotNull(resultVM.CurrentItem.entity); }
public void ReplaceItemCommand() { var db = DataRepository.GetDataRepository; Assert.NotNull(db); var user = db.Load <UserDetail>("steph"); var userManager = new UserManager(db); UserManager.GetUserManager.LoginUser(user); var cmd = new ReplaceItemCommand(); Assert.NotNull(cmd, nameof(ReplaceItemCommand)); var item = db.Load <ItemInstance>(SampleItemInstance); Assert.NotNull(item); // force known value item.status = db.ReferenceData[nameof(ItemStatus)].ByName <ItemStatus>("Available"); db.Save(item); item = db.Load <ItemInstance>(SampleItemInstance); Assert.That(item.status.name, Is.EqualTo("Available")); Assert.IsTrue(cmd.CanExecute(item)); cmd.Execute(item); Assert.That(item.status.name, Is.EqualTo("Out for Service")); // verify a new item created var searchFilter = new SearchFilterOptions { User = UserManager.GetUserManager.CurrentUser(), SiteLocationEnabled = false, SearchFilterEnabled = true, SearchText = SampleItemNumber, ItemTypeMatching = SearchFilterItemMatching.OnlyExact, //AllowItemsRemovedFromService = false, // required or query below may return old item instead of new one SelectEquipmentUnitsEnabled = false, SelectItemStatusValuesEnabled = false, SelectItemCategoryValuesEnabled = false }; Assert.NotNull(searchFilter, nameof(SearchFilterOptions)); var resultVM = new TestDetailsViewModel(); Assert.NotNull(resultVM, nameof(TestDetailsViewModel)); var onSelectionChangedCommand = new OnSelectionChangedCommand(resultVM); Assert.NotNull(onSelectionChangedCommand, nameof(OnSelectionChangedCommand)); var searchResultViewModel = new SearchResultViewModel(onSelectionChangedCommand); Assert.NotNull(searchResultViewModel, nameof(SearchResultViewModel)); var searchCmd = new SearchItemsCommand(QueryResultEntitySelector.ItemType, searchResultViewModel); Assert.NotNull(searchCmd, nameof(SearchItemsCommand)); //var searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel); //Assert.NotNull(searchFilterOptionsViewModel); Assert.IsTrue(searchCmd.CanExecute(searchFilter)); Assert.IsNull(resultVM.CurrentItem); // nothing selected to display details of Assert.That(searchResultViewModel.Items.Count, Is.EqualTo(0)); // no search results or empty search results searchCmd.Execute(searchFilter); searchCmd.WaitForSearchToComplete(); Assert.That(searchResultViewModel.Items.Count, Is.GreaterThan(0)); searchResultViewModel.SelectedItem = searchResultViewModel.Items.First(); Assert.NotNull(searchResultViewModel.SelectedItem); Assert.NotNull(resultVM.CurrentItem); Assert.That(resultVM.CurrentItem.id, Is.Not.EqualTo(item.id)); // delete new item and restore old item to Available var newItem = db.Load <ItemInstance>(resultVM.CurrentItem.id); Assert.That(newItem.status.name, Is.EqualTo("Available")); item.status = db.ReferenceData[nameof(ItemStatus)].ByName <ItemStatus>("Available"); item.removedServiceDate = null; db.Delete(newItem); Assert.IsFalse(db.Exists(newItem)); db.Save(item); item = db.Load <ItemInstance>(SampleItemInstance); Assert.That(item.status.name, Is.EqualTo("Available")); }
public void SearchGroups(String Groupname) { SearchItemsCommand.Execute(null); }
private void PopulateTiles() { if (_authContext.CheckPermission(PredefinedPermissions.MarketingPromotionsManage)) { _tileManager.AddTile(new NumberTileItem() { IdModule = NavigationNames.MenuName, IdTile = "ActivePromotions", TileTitle = "Active promotions", TileCategory = NavigationNames.ModuleName, Order = 0, IdColorSchema = TileColorSchemas.Schema3, NavigateCommand = new DelegateCommand(() => OnUIThread(async() => { if (NavigateToTabPage(NavigationNames.HomeName)) { SearchFilterState = SearchFilterStates[0]; await Task.Run(() => Thread.Sleep(300)); // we need some time to parse xaml SearchItemsCommand.Execute(); } })), Refresh = async(tileItem) => { try { using (var repository = _marketingRepository.GetRepositoryInstance()) { if (tileItem is NumberTileItem) { var query = await Task.Factory.StartNew(() => repository.Promotions.Count()); (tileItem as NumberTileItem).TileNumber = query.ToString(); } } } catch { } } }); } if (_authContext.CheckPermission(PredefinedPermissions.MarketingPromotionsManage)) { _tileManager.AddTile(new IconTileItem() { IdModule = NavigationNames.MenuName, IdTile = "NewPromotion", TileIconSource = "Icon_Module_Promotions", TileTitle = "New promotion", TileCategory = NavigationNames.ModuleName, Order = 1, IdColorSchema = TileColorSchemas.Schema1, NavigateCommand = new DelegateCommand(() => OnUIThread(async() => { if (NavigateToTabPage(NavigationNames.HomeName)) { await Task.Run(() => Thread.Sleep(300)); // we need some time to parse xaml CreateItemCommand.Execute(); } })) }); } }
public void SearchUser(String Username) { SearchItemsCommand.Execute(null); }