Skip to content

Commit

Permalink
added IAsyncEnumerable methods to test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
gentledepp committed Dec 7, 2023
1 parent 3534396 commit 15a3931
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,25 @@ public Task<Guid> AsynchronousResultMethod()
_log.Add(nameof(AsynchronousResultMethod) + ":End");
return Task.FromResult(Guid.NewGuid());
}

#if NET5_0_OR_GREATER
public async IAsyncEnumerable<string> AsynchronousEnumerableMethod()
{
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Start");
yield return "a";
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Yield a");
await Task.Delay(10).ConfigureAwait(false);
yield return "b";
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Yield b");
}

public async IAsyncEnumerable<string> AsynchronousEnumerableExceptionMethod()
{
_log.Add(nameof(AsynchronousEnumerableExceptionMethod) + ":Start");
yield return "a";
_log.Add(nameof(AsynchronousEnumerableExceptionMethod) + ":Yield a");
await Task.Delay(10).ConfigureAwait(false);
throw new InvalidOperationException(nameof(AsynchronousEnumerableExceptionMethod) + ":Exception");
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,26 @@ public async Task<Guid> AsynchronousResultMethod()
_log.Add(nameof(AsynchronousResultMethod) + ":End");
return Guid.NewGuid();
}

#if NET5_0_OR_GREATER
public async IAsyncEnumerable<string> AsynchronousEnumerableMethod()
{
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Start");
yield return "a";
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Yield a");
await Task.Delay(10).ConfigureAwait(false);
yield return "b";
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Yield b");
}

public async IAsyncEnumerable<string> AsynchronousEnumerableExceptionMethod()
{
_log.Add(nameof(AsynchronousEnumerableExceptionMethod) + ":Start");
yield return "a";
_log.Add(nameof(AsynchronousEnumerableExceptionMethod) + ":Yield a");
await Task.Delay(10).ConfigureAwait(false);
throw new InvalidOperationException(nameof(AsynchronousEnumerableExceptionMethod) + ":Exception");
}
#endif

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,25 @@ public async Task<Guid> AsynchronousResultExceptionMethod()
await Task.Delay(10).ConfigureAwait(false);
throw new InvalidOperationException(nameof(AsynchronousResultExceptionMethod) + ":Exception");
}

#if NET5_0_OR_GREATER
public async IAsyncEnumerable<string> AsynchronousEnumerableMethod()
{
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Start");
yield return "a";
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Yield a");
await Task.Delay(10).ConfigureAwait(false);
yield return "b";
_log.Add(nameof(AsynchronousEnumerableMethod) + ":Yield b");
}

public async IAsyncEnumerable<string> AsynchronousEnumerableExceptionMethod()
{
_log.Add(nameof(AsynchronousEnumerableExceptionMethod) + ":Start");
yield return "a";
_log.Add(nameof(AsynchronousEnumerableExceptionMethod) + ":Yield a");
await Task.Delay(10).ConfigureAwait(false);
throw new InvalidOperationException(nameof(AsynchronousEnumerableExceptionMethod) + ":Exception");
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ public interface IInterfaceToProxy
Task<Guid> AsynchronousResultMethod();

Task<Guid> AsynchronousResultExceptionMethod();

#if NET5_0_OR_GREATER
IAsyncEnumerable<string> AsynchronousEnumerableMethod();

IAsyncEnumerable<string> AsynchronousEnumerableExceptionMethod();
#endif
}

0 comments on commit 15a3931

Please sign in to comment.