/// <summary> /// Retrieves list of inherited processes, fills map and add items to DropDown button with inherited items. /// </summary> /// <param name="processName"> /// Process name. /// </param> /// <param name="toolbarItem"> /// Toolbar button item for "Add" command. /// </param> /// <param name="processesMap"> /// Processes map. /// </param> /// <param name="addItemCommand"> /// Command for "Add item". /// </param> public async void UpdateListOfInheritedProcesses(string processName, DropDownToolbarItemMod toolbarItem, IDictionary<string, string> processesMap, ActionCommand<object> addItemCommand) { toolbarItem.Items.Clear(); toolbarItem.IsVisible = false; processesMap.Clear(); if (string.IsNullOrWhiteSpace(processName)) { return; } if (!addItemCommand.CanExecute(null)) { return; } FindInheritedProcessRetriever res; try { res = await FindInheritedProcessRetriever.GetInheritedProcessesAsync(processName); } catch (Exception ex) { Logger.Log(LogSeverity.Error, GetType().FullName, ex); throw; } if (res == null) { return; } toolbarItem.Items.Clear(); toolbarItem.IsVisible = false; processesMap.Clear(); foreach (var baseProcess in res.InheritedProcessesList) { var editType = TheDynamicTypeManager.Value.GetEditableRootType(baseProcess.ProcessSystemName); if (editType == null || !BusinessRules.HasPermission(AuthorizationActions.CreateObject, editType)) { continue; } processesMap.Add(baseProcess.ProcessName, baseProcess.ProcessSystemName); toolbarItem.Items.Add(new ToolbarItem { Caption = baseProcess.ProcessName, Command = addItemCommand, ContentTemplate = ContentTemplates.iconNewVersionTemplate }); } if (toolbarItem.Items.Count > 1) { toolbarItem.IsVisible = true; } }
public async Task EachInheritedProcessShouldHaveToolbarItem() { var helper = new InheritanceHelper(); var inheritedList = new FindInheritedProcessRetriever { InheritedProcessesList = new MobileList<InheritedProcess> { new InheritedProcess { ProcessName = "test", ProcessSystemName = "test", ProcessId = 1 } } }; Mock.Arrange(() => FindInheritedProcessRetriever.GetInheritedProcessesAsync(Arg.IsAny<string>())).Returns(() => new Task<FindInheritedProcessRetriever>(() => inheritedList)); var toolbarItem = new DropDownToolbarItemMod(); var processMap = new Dictionary<string, string>(); helper.UpdateListOfInheritedProcesses("test", toolbarItem, processMap, new ActionCommand<object>(o => { }, o => true)); Assert.IsTrue(toolbarItem.Items.Count == 1); }
public void PropertiesTest() { var vm = new DropDownToolbarItemMod(); TestsHelper.TestPublicDeclaredPropertiesGetSet(vm, true); }