title: How to invoke WPF Dispatcher in Nunit?
body: <p>I want to test an application which renders a text block with a data field value. I would like  to get the actual width and actual height, once the rendering completes. Everything works fine. The problem came first, when I tried to test the application. I'm unable to invoke the dispatcher from the test project. </p>
  
  <p>Following is the code. </p>
  
  <pre><code>this.Loaded += (s, e) =&gt;
  {
      TextBlock textBlock1 = new TextBlock();
  
      //// Text block value is assigned from data base field.
      textBlock1.Text = strValueFromDataBaseField;        
      //// Setting the wrap behavior.
      textBlock1.TextWrapping = TextWrapping.WrapWithOverflow;
      //// Adding the text block to the layout canvas.
      this.layoutCanvas.Children.Add(textBlock1);
  
      this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
          (Action)(() =&gt;
              {
                  //// After rendering the text block with the data base field value. Measuring the actual width and height.
                 this.TextBlockActualWidth = textBlock1.ActualWidth;
                 this.TextBlockActualHeight = textBlock1.ActualHeight;
  
                 //// Other calculations based on the actual widht and actual height.
              }
          ));
  };
  </code></pre>
  
  <p>I've just started using the NUnit. So, please help me.</p>
  
  <p>Thanks</p>