Пример #1
0
 public void TestInitialize()
 {
     _testStubs.ResetTestFlags();
     StaticCommandEventStubs.ResetTestFlags();
     _canExecuteCnagedCalledStatic = false;
     _canExecuteCnagedCalled       = false;
 }
Пример #2
0
 public UnitTestWeakCommandHandlerProxy()
 {
     _testStubs = new CommandEventStubs();
     _testStubs.ResetTestFlags();
     StaticCommandEventStubs.ResetTestFlags();
     _canExecuteCnagedCalledStatic = false;
     _canExecuteCnagedCalled       = false;
 }
Пример #3
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");
        }
Пример #4
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);
        }