Exemple #1
0
        public void Create_Synchronous_NoCommandParameter_DefaultState()
        {
            IInputCommand command = Command.Create(() => { });

            Assert.IsType <RelayCommand>(command);
            Assert.True(command.CanExecute());
        }
Exemple #2
0
        public void Create_Synchronous_StronglyTypedCommandParameter_MutableState()
        {
            IInputCommand <int> command = Command.Create <int>(_ => { }, _ => false);

            Assert.IsType <RelayCommand <int> >(command);
            Assert.False(command.CanExecute(240));
        }
Exemple #3
0
        public void Create_Synchronous_StronglyTypedCommandParameter_DefaultState()
        {
            IInputCommand <int> command = Command.Create <int>(_ => { });

            Assert.IsType <RelayCommand <int> >(command);
            Assert.True(command.CanExecute(240));
        }
Exemple #4
0
        public void Create_Synchronous_NoCommandParameter_MutableState()
        {
            IInputCommand command = Command.Create(() => { }, () => false);

            Assert.IsType <RelayCommand>(command);
            Assert.False(command.CanExecute());
        }
 public static bool TryExecute(this IInputCommand command)
 {
     if (command.CanExecute())
     {
         command.Execute();
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public static bool TryExecute <T>(this IInputCommand <T> command, T parameter)
 {
     if (command.CanExecute(parameter))
     {
         command.Execute(parameter);
         return(true);
     }
     else
     {
         return(false);
     }
 }