Quiero probar una aplicación que representa un bloque de texto con un valor de campo de datos. Me gustaría obtener el ancho real y la altura real, una vez que se complete el renderizado. Todo funciona bien El problema vino primero, cuando traté de probar la aplicación. No puedo invocar al despachador desde el proyecto de prueba.¿Cómo invocar WPF Dispatcher en Nunit?
A continuación se muestra el código.
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.
}
));
};
Acabo de empezar a utilizar la NUnit. Entonces, por favor ayudame
Gracias
Exactamente, lo que estaba buscando. Gracias steven genial :) –