public async Task ReadsNullWhenContentLengthIsZero() { var bodyStream = new MemoryStream(); var reader = new HttpMessageLogBodyReader(new HashSet <string>()); var body = await reader.ReadAsync(bodyStream, MediaTypeNames.Application.Json, 0); Assert.Null(body); }
public async Task ReadsJsonWhenContentTypeIsJson() { var bodyStream = new MemoryStream(); var json = "{\"name\":\"my_name\"}"; var reader = new HttpMessageLogBodyReader(new HashSet <string>()); bodyStream.Write(Encoding.UTF8.GetBytes(json)); var body = await reader.ReadAsync(bodyStream, MediaTypeNames.Application.Json, json.Length); Assert.Equal(body?.ToString(), json); }
public async Task ReadsNullWhenContentIsIgnored() { var bodyStream = new MemoryStream(); var ignoredContents = new HashSet <string>() { MediaTypeNames.Text.Plain }; var reader = new HttpMessageLogBodyReader(ignoredContents); var body = await reader.ReadAsync(bodyStream, MediaTypeNames.Text.Plain, 0); Assert.Null(body); }