public async Task AsyncAction_ReturningUnwrappedTaskThrows() { // Arrange var inputParam1 = 1; var inputParam2 = "Second Parameter"; var actionParameters = new Dictionary <string, object> { { "i", inputParam1 }, { "s", inputParam2 } }; var methodWithUnwrappedTask = new MethodWithTaskReturnType(_controller.UnwrappedTask); var expectedException = string.Format( CultureInfo.CurrentCulture, "The method 'UnwrappedTask' on type '{0}' returned an instance of '{1}'. " + "Make sure to call Unwrap on the returned value to avoid unobserved faulted Task.", typeof(TestController), typeof(Task <Task>).FullName); // Act & Assert var ex = await Assert.ThrowsAsync <InvalidOperationException>( () => ControllerActionExecutor.ExecuteAsync( methodWithUnwrappedTask.GetMethodInfo(), _controller, actionParameters)); Assert.Equal(expectedException, ex.Message); }
public async Task AsyncAction_TaskReturnType() { int inputParam1 = 1; string inputParam2 = "Second Parameter"; var actionParameters = new Dictionary <string, object> { { "i", inputParam1 }, { "s", inputParam2 } }; var methodWithTaskReturnType = new MethodWithTaskReturnType(_controller.TaskAction); var result = await ControllerActionExecutor.ExecuteAsync( methodWithTaskReturnType.GetMethodInfo(), _controller, actionParameters); Assert.Same(null, result); }
public async Task AsyncAction_TaskReturnType() { // Arrange var inputParam1 = 1; var inputParam2 = "Second Parameter"; var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } }; var methodWithTaskReturnType = new MethodWithTaskReturnType(_controller.TaskAction); // Act var result = await ControllerActionExecutor.ExecuteAsync( methodWithTaskReturnType.GetMethodInfo(), _controller, actionParameters); // Assert Assert.Same(null, result); }
public async Task AsyncAction_TaskReturnType() { // Arrange var inputParam1 = 1; var inputParam2 = "Second Parameter"; var actionParameters = new Dictionary <string, object> { { "i", inputParam1 }, { "s", inputParam2 } }; var methodWithTaskReturnType = new MethodWithTaskReturnType(_controller.TaskAction); var result = await ExecuteAction( methodWithTaskReturnType, _controller, actionParameters); // Assert Assert.Same(null, result); }
public async Task AsyncAction_ReturningUnwrappedTaskThrows() { int inputParam1 = 1; string inputParam2 = "Second Parameter"; var actionParameters = new Dictionary <string, object> { { "i", inputParam1 }, { "s", inputParam2 } }; var methodWithUnwrappedTask = new MethodWithTaskReturnType(_controller.UnwrappedTask); await AssertThrowsAsync <InvalidOperationException>( async() => await ReflectedActionExecutor.ExecuteAsync( methodWithUnwrappedTask.GetMethodInfo(), _controller, actionParameters), string.Format(CultureInfo.CurrentCulture, "The method 'UnwrappedTask' on type '{0}' returned an instance of '{1}'. Make sure to call Unwrap on the returned value to avoid unobserved faulted Task.", typeof(TestController), typeof(Task <Task>).FullName )); }
public async Task AsyncAction_ReturningUnwrappedTaskThrows() { // Arrange var inputParam1 = 1; var inputParam2 = "Second Parameter"; var actionParameters = new Dictionary<string, object> { { "i", inputParam1 }, { "s", inputParam2 } }; var methodWithUnwrappedTask = new MethodWithTaskReturnType(_controller.UnwrappedTask); var expectedException = string.Format( CultureInfo.CurrentCulture, "The method 'UnwrappedTask' on type '{0}' returned an instance of '{1}'. " + "Make sure to call Unwrap on the returned value to avoid unobserved faulted Task.", typeof(TestController), typeof(Task<Task>).FullName); // Act & Assert var ex = await Assert.ThrowsAsync<InvalidOperationException>( () => ControllerActionExecutor.ExecuteAsync( methodWithUnwrappedTask.GetMethodInfo(), _controller, actionParameters)); Assert.Equal(expectedException, ex.Message); }