I am trying to write a test case where I have to access UI Thread. Does Nunit provide a way to access the ui thread or is there anyway I can execute some code on UI Thread in my test case. Thanks
Update: I'm using winform. The usual way is to have the presentation layer and write the test cases against it but in this situation I have a grid that I need to work with and to populate it, its DataSource property needs to be set on UI Thread.
That very much depends on which technology you are using for your UI. Depending on that it might be possible to setup the NUnit runner thread to act as your UI thread.
Genrally though, it is recommended to make the actual UI layer as thin as possible to reduce the amount of UI-code to test.
If you really need to have a live WinForms control on your NUnit thread, consider using Application.DoEvents() which will handle all currently pending events in the message queue. Be aware that doing so might bring you other problems though.
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