public void TestDefaultSerializerWithUnsafeEncoder() { var serializer = new DefaultLambdaJsonSerializer(x => x.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping); var response = new DummyResponse { BingBong = "Joy" }; MemoryStream ms = new MemoryStream(); StreamReader streamReader = new StreamReader(ms); serializer.Serialize(response, ms); ms.Seek(0, SeekOrigin.Begin); var utf8Payload = streamReader.ReadToEnd(); var albResponse = new Amazon.Lambda.ApplicationLoadBalancerEvents.ApplicationLoadBalancerResponse { Body = utf8Payload }; serializer.Serialize(albResponse, ms); ms.Seek(0, SeekOrigin.Begin); var json = streamReader.ReadToEnd(); Assert.Equal(90, json.Length); }
public void TestDefaultSerializer() { var serializer = new DefaultLambdaJsonSerializer(); var response = new DummyResponse { BingBong = "Joy" }; MemoryStream ms = new MemoryStream(); StreamReader streamReader = new StreamReader(ms); serializer.Serialize(response, ms); ms.Seek(0, SeekOrigin.Begin); var utf8Payload = streamReader.ReadToEnd(); var albResponse = new Amazon.Lambda.ApplicationLoadBalancerEvents.ApplicationLoadBalancerResponse { Body = utf8Payload }; serializer.Serialize(albResponse, ms); ms.Seek(0, SeekOrigin.Begin); var json = streamReader.ReadToEnd(); Assert.Equal(106, json.Length); }
private static InvocationResponse GetInvocationResponse(string result) { ResponseStream.SetLength(0); JsonSerializer.Serialize(result, ResponseStream); ResponseStream.Position = 0; return(new InvocationResponse(ResponseStream, false)); }
public void TestPascalCase() { var serializer = new DefaultLambdaJsonSerializer(); var response = new DummyResponse { BingBong = "Joy" }; MemoryStream ms = new MemoryStream(); serializer.Serialize(response, ms); ms.Position = 0; var json = new StreamReader(ms).ReadToEnd(); var serialized = JObject.Parse(json); Assert.Equal("Joy", serialized["BingBong"]?.ToString()); }