Skip to content

Commit

Permalink
Adjust ValueTaskTests for .NET Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Nov 13, 2024
1 parent e51cdba commit f952ddc
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,49 @@ public sealed class TestAssetFixture(AcceptanceFixture acceptanceFixture) : Test
[TestClass]
public class UnitTest1
{
private static ValueTask CompletedTask =>
#if !NET5_0_OR_GREATER
// ValueTask.CompletedTask is only available in .NET 5 and later
default;
#else
ValueTask.CompletedTask;
#endif

[AssemblyInitialize]
public static ValueTask AssemblyInitialize(TestContext testContext) => ValueTask.CompletedTask;
public static ValueTask AssemblyInitialize(TestContext testContext) => CompletedTask;

[AssemblyCleanup]
public static ValueTask AssemblyCleanup() => ValueTask.CompletedTask;
public static ValueTask AssemblyCleanup() => CompletedTask;

[ClassInitialize]
public static ValueTask ClassInitialize(TestContext testContext) => ValueTask.CompletedTask;
public static ValueTask ClassInitialize(TestContext testContext) => CompletedTask;

[ClassCleanup]
public static ValueTask ClassCleanup() => ValueTask.CompletedTask;
public static ValueTask ClassCleanup() => CompletedTask;

[TestInitialize]
public ValueTask TestInit() => ValueTask.CompletedTask;
public ValueTask TestInit() => CompletedTask;

[TestCleanup]
public ValueTask TestCleanup() => ValueTask.CompletedTask;
public ValueTask TestCleanup() => CompletedTask;

[TestMethod]
public async ValueTask TestMethod1() => await ValueTask.CompletedTask;
public async ValueTask TestMethod1() => await CompletedTask;

[TestMethod]
public ValueTask TestMethod2() => ValueTask.CompletedTask;
public ValueTask TestMethod2() => CompletedTask;

[TestMethod]
public async ValueTask FailedTestMethod()
{
await ValueTask.CompletedTask;
await CompletedTask;
Assert.Fail();
}

[TestMethod]
public async ValueTask InconclusiveTestMethod()
{
await ValueTask.CompletedTask;
await CompletedTask;
Assert.Inconclusive();
}
}
Expand Down

0 comments on commit f952ddc

Please sign in to comment.