All Questions
4 questions
10
votes
3
answers
4k
views
How to run NUnit test in STA thread?
We are in the process of porting a WPF app to .NET Core 3, preview 5.
Some NUnit tests need to run in STA threads. How can this be done?
None of the attributes like [STAThread], [RequiresSTA], ... ...
4
votes
2
answers
2k
views
NUnit async test + RequiresSTA => await not returning on STA thread
The below code:
[RequiresSTA]
[Test]
public async Task TestSta()
{
Console.WriteLine(Thread.CurrentThread.ManagedThreadId+" - "+Thread.CurrentThread.GetApartmentState());
...
4
votes
1
answer
1k
views
Unable to set WinForms clipboard in unit test
I'd like to populate the Forms.Clipboard with text from a NUnit test.
The first problem I encountered was that the Clipboard must be used in STA mode. I found the solution (NUnit 2.5.x+) to set the ...
62
votes
4
answers
31k
views
How to run unit tests in STAThread mode?
I would like to test an app that uses the Clipboard (WindowsForms) and I need the Clipboard in my unit tests also. In order to use it, it should run in STA mode, but since the NUnit TestFixture does ...