Xunit.StaFact | based tests on an STA thread
kandi X-RAY | Xunit.StaFact Summary
kandi X-RAY | Xunit.StaFact Summary
Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test. Simply use [WpfFact], [WinFormsFact], [StaFact] or the cross-platform [UIFact] on your test method to run your test under conditions that most closely match the main thread in your application. Theory variants of these attributes allow for parameterized testing. Check out the xunit.combinatorial nuget package for pairwise or combinatorial testing with theories.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Xunit.StaFact
Xunit.StaFact Key Features
Xunit.StaFact Examples and Code Snippets
[UIFact] // or [WinFormsFact] or [WpfFact]
public async Task WpfFact_OnSTAThread()
{
Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState());
int originalThread = Environment.CurrentManagedThreadId;
await Task.Yield();
Community Discussions
Trending Discussions on Xunit.StaFact
QUESTION
I have had success with some other unit tests around WPF Windows. This one has got me.
I have an xunit
test project in dotnet core 5
that has a Window. The test sets the content of a frame to a new page. However the assertion to check the content is not null will not work as the ViewNavigator content is null.
This is using Xunit.StaFact to allow running tests under STA thread.
Window ...ANSWER
Answered 2021-May-01 at 14:13Why are you synchronously blocking for 3 or 5 seconds? If WPF needs some time, you're not feeding it this way -- you're starving it.
Try changing the test method to be async, and then use await to give WPF time:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Xunit.StaFact
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page