CanExecute() public method

Defines the method that determines whether the command can execute in its current state.
public CanExecute ( object parameter ) : bool
parameter object Data used by the command. /// If the command does not require data to be passed, /// this object can be set to null.
return bool
		public void No_Execution() {
			var executed = false;
			var command = new ActionCommand(() => executed = true, () => false, false);

			var canExecute = command.CanExecute(null);
			Assert.IsFalse(canExecute);
			command.Execute(null);
			Assert.IsFalse(executed);

			var obj = new Object();
			canExecute = command.CanExecute(obj);
			Assert.IsFalse(canExecute);
			command.Execute(obj);
			Assert.IsFalse(executed);
		}
Beispiel #2
0
        public void CanExecuteReturnsFalseWhenIsEnabledIsFalse()
        {
            var command = new ActionCommand(_ => { })
            {
                IsEnabled = false
            };

            Assert.False(command.CanExecute(null));
        }
Beispiel #3
0
        /// <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;
            }
        }
Beispiel #4
0
        public void CanExecuteIsTrueByDefault()
        {
            var command = new ActionCommand(_ => { });

            Assert.True(command.CanExecute(null));
        }
        public void CanExecuteOverloadExecutesFalsePredicate()
        {
            var command = new ActionCommand(obj => { }, obj => (int)obj == 1);

            Assert.IsFalse(command.CanExecute(0));
        }
		public void New_can_execute() {
			var command = new ActionCommand();

			Assert.IsTrue(command.CanExecute(null));
			Assert.IsTrue(command.CanExecute(new Object()));
		}
        public void CommandCanBeExecutedByDefault()
        {
            var command = new ActionCommand<object>( o => { } );

            Assert.IsTrue( command.CanExecute( null ) );
        }
        public void CanExecuteTest()
        {
            var command = new ActionCommand(() => { });

            Assert.IsTrue(command.CanExecute(null));
        }
Beispiel #9
0
        public void CommandCanBeExecutedByDefault()
        {
            var command = new ActionCommand <object>(o => { });

            Assert.IsTrue(command.CanExecute(null));
        }
Beispiel #10
0
 public void the_command_is_enabled_by_default()
 {
     command.CanExecute(null).ShouldBeTrue();
 }
 public void CanExecuteOverloadExecutesTruePredciate()
 {
     var command = new ActionCommand(obj => { }, obj => (int)obj == 1);
     Assert.IsTrue(command.CanExecute(1));
 }
 public void CanExecuteOverloadExecutesFalsePredicate()
 {
     var command = new ActionCommand(obj => { }, obj => (int)obj == 1);
     Assert.IsFalse(command.CanExecute(0));
 }
 public void CanExecuteIsTrueByDefault()
 {
     var command = new ActionCommand(obj => { });
     Assert.IsTrue(command.CanExecute(null));
 }
        public void CanExecuteReturnesFalseIfPredicateReturnsFalse()
        {
            ActionCommand command = new ActionCommand(p => { }, obj => (int)obj == 1);

            Assert.IsFalse(command.CanExecute(0));
        }
        public void CanExecuteIsTrueByDefault()
        {
            ActionCommand command = new ActionCommand((parametr) => { });

            Assert.IsTrue(command.CanExecute(null));
        }