Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1.22 KB

README.md

File metadata and controls

34 lines (25 loc) · 1.22 KB

Xunit.StaFact

Build status NuGet package

This project allows for Xunit tests to run on an STA thread instead of the default MTA. It also offers attributes that apply the WPF or Windows Forms SynchronizationContexts to that thread to more fully emulate a windowed application and to ensure that async tests resume execution on the same thread as they would in a real app.

A pure portable UIFactAttribute is also offered for basic UI thread behavior that doesn't tie directly to a specific GUI framework.

Installation

This project is available as a NuGet package

Samples

[WpfFact]
public async Task WpfFact_OnSTAThread()
{
    Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState());
    await Task.Yield();
    Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState()); // still there
}

See more samples.