public override async Task <InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding) { using var streamReader = new StreamReader(context.HttpContext.Request.Body, leaveOpen: true); var textBody = await streamReader.ReadToEndAsync().ConfigureAwait(false); var product = productSerializer.TryDeserialize(textBody); if (product is null) { InputFormatterResult.Failure(); } return(InputFormatterResult.Success(product)); }
public void TryDeserialize_ValidCase_Product(string input, Product expectedResult) { var actualResult = productSerializer.TryDeserialize(input); actualResult.Should().BeEquivalentTo(expectedResult); }