public async Task GenericValueTaskWithSecondOverloadedReferenceTypeMethodAsync() { // Given var proxyFactory = CreateFactory(); var interceptor = new AsyncGenericReferenceTypeValueTaskInterceptor(); var firstExpectedReferenceType = typeof(int); var secondExpectedReferenceType = typeof(string); // When var foo = proxyFactory.CreateForInterface <IFooGenericValueTaskReferenceTypeOverloads>(interceptor); var task = foo.MethodWithOverloadAsync(firstExpectedReferenceType, secondExpectedReferenceType); var result = await task.ConfigureAwait(false); // Then Assert.NotNull(foo); Assert.Equal("foo", result); var invocation = interceptor.ForwardedInvocations.Single(); invocation.ShouldInterceptMethodWithName(nameof(IFooGenericValueTaskReferenceTypeOverloads.MethodWithOverloadAsync)); invocation.ShouldBeAsyncInvocationOfType(AsyncInvocationType.GenericValueTask); invocation.ShouldHaveParameterInCountOf(2); invocation.ShouldHaveParameterIn("first", typeof(object), firstExpectedReferenceType); invocation.ShouldHaveParameterIn("second", typeof(object), secondExpectedReferenceType); }
public async Task GenericValueTaskWithoutReferenceTypeParametersAsync() { // Given var proxyFactory = CreateFactory(); var interceptor = new AsyncGenericReferenceTypeValueTaskInterceptor(); // When var foo = proxyFactory.CreateForInterface <IFooGenericValueTaskReferenceTypeParameterless>(interceptor); var task = foo.MethodWithoutParameterAsync(); var result = await task.ConfigureAwait(false); // Then Assert.NotNull(foo); Assert.Equal("foo", result); Assert.Single(interceptor.ForwardedInvocations); var invocation = interceptor.ForwardedInvocations.Single(); invocation.ShouldInterceptMethodWithName(nameof(IFooGenericValueTaskReferenceTypeParameterless.MethodWithoutParameterAsync)); invocation.ShouldBeAsyncInvocationOfType(AsyncInvocationType.GenericValueTask); invocation.ShouldHaveNoParameterIn(); }