Skip to content

Commit

Permalink
Added LazyTask tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed Oct 18, 2023
1 parent a048297 commit 84f1c4e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Nixie.Tests/TestLazyAsync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

namespace Nixie.Tests;

public class SomeResultAsync
{

}

[Collection("Nixie")]
public class TestLazyAsync
{
[Fact]
public async Task TestAskMessageToSingleActor()
{
LazyTask<SomeResultAsync> task = CreateResultAsync();
Assert.NotNull(await task);
}

private async LazyTask<SomeResultAsync> CreateResultAsync()
{
await Task.Delay(100);
return new SomeResultAsync();
}
}
6 changes: 5 additions & 1 deletion Nixie/LazyTaskMethodBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

#pragma warning disable CA1000

using System.Runtime.CompilerServices;

namespace Nixie;
Expand All @@ -7,7 +9,7 @@ public class LazyTaskMethodBuilder<T>
{
public LazyTaskMethodBuilder() => Task = new LazyTask<T>();

//public static LazyTaskMethodBuilder<T> Create() => new();
public static LazyTaskMethodBuilder<T> Create() => new();

public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine
{
Expand Down Expand Up @@ -42,3 +44,5 @@ public void GenericAwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaite

public LazyTask<T> Task { get; }
}

#pragma warning restore CA1000

0 comments on commit 84f1c4e

Please sign in to comment.