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

            Assert.IsType <RelayCommand>(command);
            Assert.True(command.CanExecute());
        }
示例#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));
        }
示例#3
0
        public void Create_Synchronous_StronglyTypedCommandParameter_DefaultState()
        {
            IInputCommand <int> command = Command.Create <int>(_ => { });

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

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