Ich möchte eine Anwendung testen, die einen Textblock mit einem Datenfeldwert rendert. Ich möchte die tatsächliche Breite und tatsächliche Höhe erhalten, sobald das Rendering abgeschlossen ist. Alles funktioniert gut. Das Problem kam zuerst, als ich versuchte, die Anwendung zu testen. Ich kann den Dispatcher vom Testprojekt nicht aufrufen.Wie WPF Dispatcher in Nunit aufrufen?
Folgendes ist der Code.
this.Loaded += (s, e) =>
{
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)(() =>
{
//// 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.
}
));
};
Ich habe gerade mit der NUnit begonnen. Also, bitte hilf mir.
Dank
Genau, wonach ich gesucht habe. Danke Steven toll :) –