Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;
namespace XUnitMany
{
public class Class1
{
[Fact]
public void Test11()
{
Console.WriteLine("P11B");
Thread.Sleep(5000);
Console.WriteLine("P11E");
}
[Fact]
public void Test12()
{
Console.WriteLine("P12B");
Thread.Sleep(5000);
Console.WriteLine("P12E");
}
}
public class Class2
{
public Class2()
{
Thread.Sleep(1000);
}
[Fact]
public void Test21()
{
Console.WriteLine("P21B");
Thread.Sleep(5000);
Console.WriteLine("P21E");
}
[Fact]
[SleepBeforeAndAfer]
public void Test22()
{
Console.WriteLine("P22B");
Thread.Sleep(5000);
Console.WriteLine("P22E");
}
[Fact]
[SleepBeforeAndAfer]
public Task Test23()
{
Console.WriteLine("P22B");
Thread.Sleep(5000);
Console.WriteLine("P22E");
return Task.Delay(1);
}
}
public class SleepBeforeAndAfer : BeforeAfterTestAttribute
{
public override void Before(MethodInfo methodUnderTest)
{
Thread.Sleep(2000);
}
public override void After(MethodInfo methodUnderTest)
{
Thread.Sleep(2000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment