示例#1
0
        public async Task Can_invoke_api_gateway_lambda_function()
        {
            var request = new APIGatewayProxyRequest
            {
                Body           = "{ \"a\" = \"b\" }",
                HttpMethod     = "GET",
                Path           = "/foo/bar",
                RequestContext = new APIGatewayProxyRequest.ProxyRequestContext
                {
                    HttpMethod = "GET",
                    Path       = "/foo/bar"
                }
            };
            var invokeResponse = await _lambdaClient.InvokeRequestAsync("APIGatewayFunction", request);

            invokeResponse.StatusCode.ShouldBe(200);
            invokeResponse.Payload.Length.ShouldBeGreaterThan(0);

            var streamReader = new StreamReader(invokeResponse.Payload);
            var payload      = await streamReader.ReadToEndAsync();

            var apiGatewayProxyResponse = JsonSerializer.Deserialize <APIGatewayProxyResponse>(payload);

            apiGatewayProxyResponse.IsBase64Encoded.ShouldBeFalse();
            apiGatewayProxyResponse.Body.ShouldNotBeNullOrWhiteSpace();
        }