private async Task <APIGatewayProxyResponse> InvokeAPIGatewayRequestWithContent(TestLambdaContext context, string requestContent) { var lambdaFunction = new ApiGatewayLambdaFunction(); var requestStream = new MemoryStream(System.Text.UTF8Encoding.UTF8.GetBytes(requestContent)); var request = new Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer().Deserialize <APIGatewayProxyRequest>(requestStream); return(await lambdaFunction.FunctionHandlerAsync(request, context)); }
private async Task <APIGatewayHttpApiV2ProxyResponse> InvokeAPIGatewayRequestWithContent(TestLambdaContext context, string requestContent) { var lambdaFunction = new TestWebApp.HttpV2LambdaFunction(); var requestStream = new MemoryStream(System.Text.UTF8Encoding.UTF8.GetBytes(requestContent)); #if NETCOREAPP_2_1 var request = new Amazon.Lambda.Serialization.Json.JsonSerializer().Deserialize <APIGatewayHttpApiV2ProxyRequest>(requestStream); #else var request = new Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer().Deserialize <APIGatewayHttpApiV2ProxyRequest>(requestStream); #endif return(await lambdaFunction.FunctionHandlerAsync(request, context)); }
private async Task <IMethodsCalled> InvokeAPIGatewayRequestWithContent(Type functionType) { var context = new TestLambdaContext(); var filePath = Path.Combine(Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location), "values-get-all-apigateway-request.json"); var requestContent = File.ReadAllText(filePath); var lambdaFunction = Activator.CreateInstance(functionType) as APIGatewayProxyFunction; var requestStream = new MemoryStream(System.Text.UTF8Encoding.UTF8.GetBytes(requestContent)); var request = new Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer().Deserialize <APIGatewayProxyRequest>(requestStream); var response = await lambdaFunction.FunctionHandlerAsync(request, context); Assert.Equal(200, response.StatusCode); return(lambdaFunction as IMethodsCalled); }