コード例 #1
0
        public void NullActionExecution()
        {
            var invoked           = false;
            var canExecuteInvoked = false;

            var rc = new EventCommand();

            rc.OnCanExecuted += (s, a) => { canExecuteInvoked = true; };

            Assert.IsFalse(invoked);
            Assert.IsFalse(canExecuteInvoked);

            rc.Execute();

            Assert.IsFalse(invoked);
            Assert.IsFalse(canExecuteInvoked);

            void onExecuteEvent(object s, EventArgs a)
            {
                invoked = true;
            }

            rc.OnExecuted    += onExecuteEvent;
            rc.OnCanExecuted += (s, a) => rc.OnExecuted -= onExecuteEvent;

            rc.Execute();

            Assert.IsFalse(invoked);
            Assert.IsTrue(canExecuteInvoked);
        }
コード例 #2
0
        public void NullActionExecution()
        {
            var invoked           = false;
            var canExecuteInvoked = false;

            var rc = new EventCommand <int>();

            rc.OnCanExecuted += (s, a) => { canExecuteInvoked = true; };

            Assert.IsFalse(invoked);
            Assert.IsFalse(canExecuteInvoked);

            rc.Execute(0);
            Assert.IsFalse(invoked);
            Assert.IsFalse(canExecuteInvoked);

            EventHandler <int> onExecuteEvent = (s, a) => { invoked = true; };

            rc.OnExecuted    += onExecuteEvent;
            rc.OnCanExecuted += (s, a) => rc.OnExecuted -= onExecuteEvent;

            rc.Execute(0);

            Assert.IsFalse(invoked);
            Assert.IsTrue(canExecuteInvoked);
        }
コード例 #3
0
 private void EventHandler(object sender, RoutedEventArgs e)
 {
     if (EventCommand != null)
     {
         EventCommand.Execute(Target ?? (this));
     }
 }
コード例 #4
0
        public void ActionPredicateInvocation()
        {
            var invoked           = false;
            var canExecuteInvoked = false;

            var rc = new EventCommand();

            rc.OnExecuted    += (s, a) => invoked = true;
            rc.OnCanExecuted += (s, a) => { canExecuteInvoked = true; a.CanExecute = true; };

            Assert.IsFalse(invoked);
            Assert.IsFalse(canExecuteInvoked);

            Assert.IsTrue(((ICommand)rc).CanExecute(null));

            Assert.IsFalse(invoked);
            Assert.IsTrue(canExecuteInvoked);

            canExecuteInvoked = false;

            rc.Execute();

            Assert.IsTrue(invoked);
            Assert.IsTrue(canExecuteInvoked);
        }
コード例 #5
0
        public void ParameterTransferTest()
        {
            var param = 12356;

            var rc = new EventCommand <int>();

            rc.OnExecuted    += (s, i) => Assert.AreEqual(param, i);
            rc.OnCanExecuted += (s, a) => Assert.AreEqual(param, a.Parameter);

            rc.Execute(param);
        }
コード例 #6
0
        public void ActionInvokation()
        {
            var invoked = false;

            var rc = new EventCommand();

            rc.OnExecuted += (s, a) => invoked = true;

            Assert.IsFalse(invoked);

            rc.Execute();

            Assert.IsTrue(invoked);
        }
コード例 #7
0
        public void ActionPreventExecution()
        {
            var invoked           = false;
            var canExecuteInvoked = false;

            var rc = new EventCommand();

            rc.OnExecuted    += (s, a) => invoked = true;
            rc.OnCanExecuted += (s, a) => { canExecuteInvoked = true; a.CanExecute = false; };

            Assert.IsFalse(invoked);
            Assert.IsFalse(canExecuteInvoked);

            rc.Execute();

            Assert.IsFalse(invoked);
            Assert.IsTrue(canExecuteInvoked);
        }
コード例 #8
0
ファイル: EventHandlerInfo.cs プロジェクト: mrgrayhat/MvvmGo
 public void Run <T1, T2, T3, T4>(T1 value1, T2 value2, T3 value3, T4 value4)
 {
     //if (CommandParameter == null)
     SetCommandParameter();
     EventCommand.Execute(CommandParameter, value1, value2, value3, value4);
 }
コード例 #9
0
ファイル: EventHandlerInfo.cs プロジェクト: mrgrayhat/MvvmGo
 public void Run <T1, T2>(T1 value1, T2 value2)
 {
     //if (CommandParameter == null)
     SetCommandParameter();
     EventCommand.Execute(CommandParameter, value1, value2);
 }
コード例 #10
0
ファイル: EventHandlerInfo.cs プロジェクト: mrgrayhat/MvvmGo
 public void Run()
 {
     //if (CommandParameter == null)
     SetCommandParameter();
     EventCommand.Execute(CommandParameter);
 }