public async Task GenericValueTaskWithSecondOverloadedValueTypeMethodAsync() { // Given var proxyFactory = CreateFactory(); var interceptor = new AsyncGenericValueTypeValueTaskInterceptor(); var firstExpectedValueType = 13; var secondExpectedValueType = 42.0; // When var foo = proxyFactory.CreateForInterface <IFooGenericValueTaskValueTypeOverloads>(interceptor); var task = foo.MethodWithOverloadAsync(firstExpectedValueType, secondExpectedValueType); var result = await task.ConfigureAwait(false); // Then Assert.NotNull(foo); Assert.Equal(42, result); var invocation = interceptor.ForwardedInvocations.Single(); invocation.ShouldInterceptMethodWithName(nameof(IFooGenericValueTaskValueTypeOverloads.MethodWithOverloadAsync)); invocation.ShouldBeAsyncInvocationOfType(AsyncInvocationType.GenericValueTask); invocation.ShouldHaveParameterInCountOf(2); invocation.ShouldHaveParameterIn("first", typeof(int), firstExpectedValueType); invocation.ShouldHaveParameterIn("second", typeof(double), secondExpectedValueType); }
public async Task GenericValueTaskWithoutValueTypeParametersAsync() { // Given var proxyFactory = CreateFactory(); var interceptor = new AsyncGenericValueTypeValueTaskInterceptor(); // When var foo = proxyFactory.CreateForInterface <IFooGenericValueTaskValueTypeParameterless>(interceptor); var task = foo.MethodWithoutParameterAsync(); var result = await task.ConfigureAwait(false); // Then Assert.NotNull(foo); Assert.Equal(42, result); Assert.Single(interceptor.ForwardedInvocations); var invocation = interceptor.ForwardedInvocations.Single(); invocation.ShouldInterceptMethodWithName(nameof(IFooGenericValueTaskValueTypeParameterless.MethodWithoutParameterAsync)); invocation.ShouldBeAsyncInvocationOfType(AsyncInvocationType.GenericValueTask); invocation.ShouldHaveNoParameterIn(); }