Example #1
0
        public void CommandHandlerProxyCanExecuteChangedBoolProperty()
        {
            PropertyInfo boolPropertyInfo = _testStubs.GetPropertyInfo("CanExecuteFlag");
            var          chp = new WeakCommandHandlerProxy(_testStubs.ExecuteButton_Click_External, boolPropertyInfo, _testStubs);

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

            Assert.AreEqual(result, false, "Target delegate for ICommand:CanExecute() return wrong flag");
            _testStubs.CanExecuteFlag = true;

            chp.Execute(null);
            result = chp.CanExecute(null);
            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");
        }
Example #2
0
        public void CommandHandlerProxyCanExecuteChangedBoolProperty()
        {
            PropertyInfo boolPropertyInfo = _testStubs.GetPropertyInfo("CanExecuteFlag");
            var          chp = new WeakCommandHandlerProxy(_testStubs.ExecuteButton_Click_External, boolPropertyInfo, _testStubs);

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

            Assert.Equal(result, false);
            _testStubs.CanExecuteFlag = true;

            chp.Execute(null);
            result = chp.CanExecute(null);
            Assert.Equal(_testStubs.ExecuteButtonClickExternalCalled, true);
            Assert.Equal(_testStubs.CanExecuteButtonClickExternalFlag, true);
            Assert.Equal(result, true);
            Assert.Equal(_canExecuteCnagedCalled, true);
        }
Example #3
0
        public void StaticCommandHandlerProxyCanExecuteTest()
        {
            var chp = new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, StaticCommandEventStubs.CanExecuteButton_Click_External);

            chp.Execute(null);
            bool result = chp.CanExecute(null);

            Assert.AreEqual(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true, "Target delegate for ICommand:CanExecute() was not called for static");
            Assert.AreEqual(StaticCommandEventStubs.CanExecuteButtonClickExternalFlag, true, "Target delegate for ICommand:CanExecute() was not called for static");
            Assert.AreEqual(result, true, "Target delegate for ICommand:CanExecute() retrun wrong flag");
        }
Example #4
0
        public void StaticCommandHandlerProxyCanExecuteTest()
        {
            var chp = new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, StaticCommandEventStubs.CanExecuteButton_Click_External);

            chp.Execute(null);
            bool result = chp.CanExecute(null);

            Assert.Equal(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true);
            Assert.Equal(StaticCommandEventStubs.CanExecuteButtonClickExternalFlag, true);
            Assert.Equal(result, true);
        }
Example #5
0
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTestDelegate()
        {
            Action invokeNotify = null;
            var    chp          = new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, StaticCommandEventStubs.CanExecuteButton_Click_External, a => invokeNotify = a);

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

            invokeNotify();
            Assert.AreEqual(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true, "Target delegate for ICommand:Execute() was not called for static");
            Assert.AreEqual(StaticCommandEventStubs.CanExecuteButtonClickExternalFlag, true, "Target delegate for ICommand:Execute() was not called for static");
            Assert.AreEqual(result, true, "Target delegate for ICommand:CanExecute() return wrong flag");
            Assert.AreEqual(_canExecuteCnagedCalledStatic, true, "ICommand:CanExecuteChanged event was not risen");
        }
Example #6
0
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = typeof(StaticCommandEventStubs).GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, StaticCommandEventStubs.CanExecuteButton_Click_External, outerEvent);

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

            StaticCommandEventStubs.InvokeNotifyChanged();
            Assert.AreEqual(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true, "Target delegate for ICommand:Execute() was not called for static");
            Assert.AreEqual(StaticCommandEventStubs.CanExecuteButtonClickExternalFlag, true, "Target delegate for ICommand:Execute() was not called for static");
            Assert.AreEqual(result, true, "Target delegate for ICommand:CanExecute() return wrong flag");
            Assert.AreEqual(_canExecuteCnagedCalledStatic, true, "ICommand:CanExecuteChanged event was not risen");
        }
Example #7
0
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTestDelegate()
        {
            Action invokeNotify = null;
            var    chp          = new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, StaticCommandEventStubs.CanExecuteButton_Click_External, a => invokeNotify = a);

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

            invokeNotify();
            Assert.Equal(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true);
            Assert.Equal(StaticCommandEventStubs.CanExecuteButtonClickExternalFlag, true);
            Assert.Equal(result, true);
            Assert.Equal(_canExecuteCnagedCalledStatic, true);
        }
Example #8
0
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = typeof(StaticCommandEventStubs).GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, StaticCommandEventStubs.CanExecuteButton_Click_External, outerEvent);

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

            StaticCommandEventStubs.InvokeNotifyChanged();
            Assert.Equal(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true);
            Assert.Equal(StaticCommandEventStubs.CanExecuteButtonClickExternalFlag, true);
            Assert.Equal(result, true);
            Assert.Equal(_canExecuteCnagedCalledStatic, true);
        }