From 15a393155308aacb373f79122cbb6c543d1ba2d4 Mon Sep 17 00:00:00 2001 From: amarek Date: Thu, 7 Dec 2023 10:28:48 +0100 Subject: [PATCH] added IAsyncEnumerable methods to test classes --- .../ClassWithAlwaysCompletedAsync.cs | 21 ++++++++++++++++++ .../ClassWithAlwaysIncompleteAsync.cs | 22 +++++++++++++++++++ .../ClassWithInterfaceToProxy.cs | 21 ++++++++++++++++++ .../InterfaceProxies/IInterfaceToProxy.cs | 6 +++++ 4 files changed, 70 insertions(+) diff --git a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysCompletedAsync.cs b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysCompletedAsync.cs index 3609436..db75db1 100644 --- a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysCompletedAsync.cs +++ b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysCompletedAsync.cs @@ -57,4 +57,25 @@ public Task AsynchronousResultMethod() _log.Add(nameof(AsynchronousResultMethod) + ":End"); return Task.FromResult(Guid.NewGuid()); } + +#if NET5_0_OR_GREATER + public async IAsyncEnumerable 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 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 } diff --git a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysIncompleteAsync.cs b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysIncompleteAsync.cs index 7c4b345..5bc9e2e 100644 --- a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysIncompleteAsync.cs +++ b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithAlwaysIncompleteAsync.cs @@ -58,4 +58,26 @@ public async Task AsynchronousResultMethod() _log.Add(nameof(AsynchronousResultMethod) + ":End"); return Guid.NewGuid(); } + +#if NET5_0_OR_GREATER + public async IAsyncEnumerable 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 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 + } diff --git a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithInterfaceToProxy.cs b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithInterfaceToProxy.cs index d398c4a..32c9029 100644 --- a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithInterfaceToProxy.cs +++ b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/ClassWithInterfaceToProxy.cs @@ -73,4 +73,25 @@ public async Task AsynchronousResultExceptionMethod() await Task.Delay(10).ConfigureAwait(false); throw new InvalidOperationException(nameof(AsynchronousResultExceptionMethod) + ":Exception"); } + +#if NET5_0_OR_GREATER + public async IAsyncEnumerable 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 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 } diff --git a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/IInterfaceToProxy.cs b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/IInterfaceToProxy.cs index f09c524..2fe49a6 100644 --- a/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/IInterfaceToProxy.cs +++ b/test/Castle.Core.AsyncInterceptor.Tests/InterfaceProxies/IInterfaceToProxy.cs @@ -22,4 +22,10 @@ public interface IInterfaceToProxy Task AsynchronousResultMethod(); Task AsynchronousResultExceptionMethod(); + +#if NET5_0_OR_GREATER + IAsyncEnumerable AsynchronousEnumerableMethod(); + + IAsyncEnumerable AsynchronousEnumerableExceptionMethod(); +#endif }