Exemple #1
0
        public void CommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = _testStubs.GetType().GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new WeakCommandHandlerProxy(_testStubs.ExecuteButton_Click_External, _testStubs.CanExecuteButton_Click_External, outerEvent, _testStubs);

            chp.CanExecuteChanged += CanExecuteChangedTest;
            chp.Execute(null);
            bool result = chp.CanExecute(null);

            _testStubs.InvokeNotifyChanged();

            Assert.AreEqual(_testStubs.ExecuteButtonClickExternalCalled, true, "Target delegate for ICommand:Execute() was not called");
            Assert.AreEqual(_testStubs.CanExecuteButtonClickExternalFlag, true, "Target delegate for ICommand:Execute() was not called");
            Assert.AreEqual(result, true, "Target delegate for ICommand:CanExecute() return wrong flag");
            Assert.AreEqual(_canExecuteCnagedCalled, true, "ICommand:CanExecuteChanged event was not risen");
        }
Exemple #2
0
        public void CommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = _testStubs.GetType().GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new WeakCommandHandlerProxy(_testStubs.ExecuteButton_Click_External, _testStubs.CanExecuteButton_Click_External, outerEvent, _testStubs);

            chp.CanExecuteChanged += CanExecuteChangedTest;
            chp.Execute(null);
            bool result = chp.CanExecute(null);

            _testStubs.InvokeNotifyChanged();

            Assert.Equal(_testStubs.ExecuteButtonClickExternalCalled, true);
            Assert.Equal(_testStubs.CanExecuteButtonClickExternalFlag, true);
            Assert.Equal(result, true);
            Assert.Equal(_canExecuteCnagedCalled, true);
        }