public async Task ReadFromStreamAsync_NullContent_ReturnsDefault( MultipartJsonMediaTypeFormatter sut, Type type, IFormatterLogger formatterLogger) { var actual = await sut.ReadFromStreamAsync(type, null, null, formatterLogger); var expected = MediaTypeFormatter.GetDefaultValueForType(type); Assert.Equal(expected, actual); }
public async Task ReadFromStreamAsync_NotJsonObjectContent_Throws( MultipartJsonMediaTypeFormatter sut, MultipartFormDataContent content, ObjectContent<string> stringContent, IFormatterLogger formatterLogger) { content.Add(stringContent, "StringValue"); // HACK: ContentLength set just to bypass sanity checks in ReadFromStreamAsync. content.Headers.ContentLength = 1; await Assert.ThrowsAsync<InvalidOperationException>(() => sut.ReadFromStreamAsync(typeof(string), null, content, formatterLogger)); }
public async Task ReadFromStreamAsync_ContentNotMultipartFormData_ThrowsInvalidOperationException( MultipartJsonMediaTypeFormatter sut, ObjectContent<string> content, IFormatterLogger formatterLogger) { Assert.False(content.IsMimeMultipartContent()); await Assert.ThrowsAsync<InvalidOperationException>(() => sut.ReadFromStreamAsync(content.ObjectType, null, content, formatterLogger)); }