Created
January 20, 2021 11:32
-
-
Save JoachimL/525ad718cdd14d4f6c6da9ed8ab17941 to your computer and use it in GitHub Desktop.
PoC'ing the use of shared state in Xunit tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using Xunit; | |
namespace Xunit.ContextPoC | |
{ | |
public class UnitTest1 : IClassFixture<Context> | |
{ | |
public UnitTest1(Context ctx) | |
{ | |
Ctx = ctx; | |
} | |
public Context Ctx { get; } | |
[Fact] | |
public void Test1() | |
{ | |
Assert.NotNull(Ctx.JsonPayload); | |
} | |
[Fact] | |
public void Test2() | |
{ | |
Assert.NotNull(Ctx.JsonPayload); | |
} | |
} | |
public class Context | |
{ | |
public readonly string JsonPayload; | |
public Context() | |
{ | |
Thread.Sleep(5000); | |
JsonPayload = "{'value':'1000'}"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment