public async void DiposeExecutionContextTestAsync() { var invocationRequest = new TestFunctionInvocation(); invocationRequest.FunctionId = "123"; var functionDescriptor = new TestFunctionMetadata(); functionDescriptor.FunctionId = "123"; var definition = new TestFunctionDefinition { Metadata = functionDescriptor }; var context = new TestFunctionExecutionContext(); _mockFunctionDefinitionFactory.Setup(p => p.Create(It.IsAny <FunctionLoadRequest>())).Returns(definition); _mockFunctionExecutionContextFactory.Setup(p => p.Create(It.IsAny <FunctionInvocation>(), definition)).Returns(context); _mockFunctionExecutionDelegate.Setup(p => p(It.IsAny <FunctionExecutionContext>())).Returns(Task.CompletedTask); _functionBroker.AddFunction(It.IsAny <FunctionLoadRequest>()); var result = await _functionBroker.InvokeAsync(invocationRequest); Assert.Equal(StatusResult.Types.Status.Success, result.Result.Status); Assert.True(context.IsDisposed); }
private FunctionExecutionContext CreateContext(MethodInfo mi) { var context = new TestFunctionExecutionContext(); var metadata = new TestFunctionMetadata(); var parameters = mi.GetParameters().Select(p => new FunctionParameter(p.Name, p.ParameterType)); context.FunctionDefinition = new DefaultFunctionDefinition(metadata, _functionInvokerFactory.Create(mi), parameters); return(context); }