Esempio n. 1
0
        public void StaticCommandHandlerProxyExecuteTest()
        {
            var chp = new CommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External);

            chp.Execute(null);
            Assert.Equal(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true);
        }
        public void StaticCommandHandlerProxyExecuteTest()
        {
            var chp = new CommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External);

            chp.Execute(null);
            Assert.AreEqual(StaticCommandEventStubs.ExecuteButtonClickExternalCalled, true, "Target delegate for ICommand:Execute() was called for static");
        }
        public void StaticCommandHandlerProxyCanExecuteTest()
        {
            var chp = new CommandHandlerProxy(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");
        }
Esempio n. 4
0
        public void StaticCommandHandlerProxyCanExecuteTest()
        {
            var chp = new CommandHandlerProxy(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);
        }
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTestDelegate()
        {
            Action invokeNotify = null;
            var    chp          = new CommandHandlerProxy(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");
        }
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = typeof(StaticCommandEventStubs).GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new CommandHandlerProxy(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");
        }
Esempio n. 7
0
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTestDelegate()
        {
            Action invokeNotify = null;
            var    chp          = new CommandHandlerProxy(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);
        }
Esempio n. 8
0
        public void StaticCommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = typeof(StaticCommandEventStubs).GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new CommandHandlerProxy(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);
        }
        public void CommandHandlerProxyCanExecuteChangedBoolProperty()
        {
            PropertyInfo boolPropertyInfo = _testStubs.GetPropertyInfo("CanExecuteFlag");
            var          chp = new CommandHandlerProxy(_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");
        }
Esempio n. 10
0
        public void CommandHandlerProxyCanExecuteChangedBoolProperty()
        {
            PropertyInfo boolPropertyInfo = _testStubs.GetPropertyInfo("CanExecuteFlag");
            var          chp = new CommandHandlerProxy(_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);
        }
        public void CommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = _testStubs.GetType().GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new CommandHandlerProxy(_testStubs.ExecuteButton_Click_External, _testStubs.CanExecuteButton_Click_External, outerEvent, _testStubs);

            Assert.AreEqual(_testStubs.IsNullIssueNotifyExecuteButtonChanged, true, "Event should not be set");
            chp.CanExecuteChanged += CanExecuteChangedTest;
            Assert.AreEqual(_testStubs.IsNullIssueNotifyExecuteButtonChanged, false, "Event should be set");
            chp.Execute(null);
            bool result = chp.CanExecute(null);

            _testStubs.InvokeNotifyChanged();
            chp.CanExecuteChanged -= CanExecuteChangedTest;
            Assert.AreEqual(_testStubs.IsNullIssueNotifyExecuteButtonChanged, true, "Event should not be set");
            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");
        }
Esempio n. 12
0
        public void CommandHandlerProxyNotifyCanExecuteChangedTest()
        {
            EventInfo outerEvent = _testStubs.GetType().GetEvent("IssueNotifyExecuteButtonChanged");
            var       chp        = new CommandHandlerProxy(_testStubs.ExecuteButton_Click_External, _testStubs.CanExecuteButton_Click_External, outerEvent, _testStubs);

            Assert.Equal(_testStubs.IsNullIssueNotifyExecuteButtonChanged, true);
            chp.CanExecuteChanged += CanExecuteChangedTest;
            Assert.Equal(_testStubs.IsNullIssueNotifyExecuteButtonChanged, false);
            chp.Execute(null);
            bool result = chp.CanExecute(null);

            _testStubs.InvokeNotifyChanged();
            chp.CanExecuteChanged -= CanExecuteChangedTest;
            Assert.Equal(_testStubs.IsNullIssueNotifyExecuteButtonChanged, true);
            Assert.Equal(_testStubs.ExecuteButtonClickExternalCalled, true);
            Assert.Equal(_testStubs.CanExecuteButtonClickExternalFlag, true);
            Assert.Equal(result, true);
            Assert.Equal(_canExecuteCnagedCalled, true);
        }
Esempio n. 13
0
            /// <summary>
            /// Just Constructor
            /// </summary>

            public _TestBindEventHandlerIoc()
            {
                CommandProxy = new CommandHandlerProxy(ExecuteMethod);
            }