Is it possible to test my WPF UserControls from NUnit (or similar)? If I create an instance of the usercontrol in a unit test like so:
// Create an instance of the WPF UserControl
var view = new ChildrenListView();
I get the following error:
"The calling thread must be STA, because many UI components require this"
I get the feeling I'm missing something very important here.
Use the [STAThread] attribute.
[Test]
[STAThread]
public void TestConstructorDoesNotThrow()
{
Expect(() => new ChildrenListView(), Throws.Nothing);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With