public async Task TaskWithSingleValueTypeParameterAsync() { // Given var proxyFactory = Context.ProxyFactory; var interceptor = new AsyncInterceptor(false); var expectedValueType = 13; var decoratee = new FooTaskValueTypeParameter(); // When var foo = proxyFactory.CreateDecorator <IFooTaskValueTypeParameter>(decoratee, interceptor); var task = foo.MethodWithOneParameterAsync(expectedValueType); await task.ConfigureAwait(false); // Then Assert.NotNull(foo); Assert.Equal(1u, decoratee.CallCount); Assert.Equal(expectedValueType, decoratee.Parameter); Assert.Single(interceptor.ForwardedInvocations); var invocation = interceptor.ForwardedInvocations.Single(); invocation.ShouldInterceptMethodWithName(nameof(IFooTaskValueTypeParameter.MethodWithOneParameterAsync)); invocation.ShouldBeAsyncInvocationOfType(AsyncInvocationType.Task); invocation.ShouldHaveParameterInCountOf(1); invocation.ShouldHaveParameterIn("first", typeof(int), expectedValueType); }
public async Task TaskWithSingleValueTypeParameterInterceptedAsync() { // Given var proxyFactory = Context.ProxyFactory; var interceptor = new AsyncInterceptor(true); var expectedValueType = 13; var decoratee = new FooTaskValueTypeParameter(); // When var foo = proxyFactory.CreateDecorator <IFooTaskValueTypeParameter>(decoratee, interceptor); var task = foo.MethodWithOneParameterAsync(expectedValueType); await task.ConfigureAwait(false); // Then Assert.NotNull(foo); Assert.Equal(0u, decoratee.CallCount); Assert.Equal(default, decoratee.Parameter);