Ejemplo n.º 1
0
        public void TestOnRequestDispatcherBeginInvoke()
        {
            //Arrange
            //We need to create an event and include an exception
            EvaluationCompletedEventArgs e = new EvaluationCompletedEventArgs(true, new Exception("Test"));

            //This will subcribe to the EvaluationCompleted event
            CurrentDynamoModel.EvaluationCompleted += CurrentDynamoModel_EvaluationCompleted;

            //Act
            //This will call the OnRequestDispatcherBeginInvoke method in the else section (no subscribers to the event)
            CurrentDynamoModel.OnEvaluationCompleted(this, e);

            //This will subscribe our local method to the RequestDispatcherBeginInvoke event
            DynCmd.RequestDispatcherBeginInvoke += DynamoModel_RequestDispatcherBeginInvoke;

            //This will call the OnRequestDispatcherBeginInvoke method when we have subscribers
            CurrentDynamoModel.OnEvaluationCompleted(this, e);

            //Assert
            DynCmd.RequestDispatcherBeginInvoke    -= DynamoModel_RequestDispatcherBeginInvoke;
            CurrentDynamoModel.EvaluationCompleted -= CurrentDynamoModel_EvaluationCompleted;
            //This will validate that the local handler was executed and set the flag in true
            Assert.IsTrue(dispatcherExecuted);
            Assert.IsTrue(evaluationCompleted);
        }