public void SingleValue() { var apiGatewayHeaders = new Dictionary <string, string>(); StringValues aspNetCoreCookies = new StringValues("Foo"); APIGatewayProxyFunction.ProcessCookies(apiGatewayHeaders, aspNetCoreCookies); Assert.Single(apiGatewayHeaders); }
/// <summary> /// An overload of FunctionHandlerAsync to allow working with the typed API Gateway event classes. Implemented as an extension /// method to avoid confusion of using it as the function handler for the Lambda function. /// </summary> /// <param name="function"></param> /// <param name="request"></param> /// <param name="lambdaContext"></param> /// <returns></returns> public static async Task <APIGatewayProxyResponse> FunctionHandlerAsync(this APIGatewayProxyFunction function, APIGatewayProxyRequest request, ILambdaContext lambdaContext) { ILambdaSerializer serializer = new Amazon.Lambda.Serialization.Json.JsonSerializer(); var requestStream = new MemoryStream(); serializer.Serialize <APIGatewayProxyRequest>(request, requestStream); requestStream.Position = 0; var responseStream = await function.FunctionHandlerAsync(requestStream, lambdaContext); var response = serializer.Deserialize <APIGatewayProxyResponse>(responseStream); return(response); }
public void HundredCookies() { var list = new List <string>(); for (int i = 0; i < 100; i++) { list.Add($"Bar{i}"); } var apiGatewayHeaders = new Dictionary <string, string>(); StringValues aspNetCoreCookies = new StringValues(list.ToArray()); APIGatewayProxyFunction.ProcessCookies(apiGatewayHeaders, aspNetCoreCookies); Assert.Equal(100, apiGatewayHeaders.Count); foreach (var key in apiGatewayHeaders.Keys) { Assert.Equal("set-cookie", key.ToLower()); } }