public async Task RootContent_ReturnsNullIfContentIDIsNotMatched(string mediaType) { // Arrange MultipartContent content = new MultipartContent("related", Boundary); content.Headers.ContentType = MediaTypeHeaderValue.Parse(mediaType); content.Add(new StringContent(DefaultRootContent)); content.Add(new StringContent(OtherContent)); HttpContent expectedRootContent = new StringContent(ContentIDRootContent); expectedRootContent.Headers.Add("Content-ID", "NoMatch"); content.Add(expectedRootContent); MultipartRelatedStreamProvider provider = await content.ReadAsMultipartAsync( new MultipartRelatedStreamProvider() ); // Act HttpContent actualRootContent = provider.RootContent; // Assert Assert.Null(actualRootContent); }
public async Task RootContent_PicksContent(string mediaType, bool hasStartParameter) { // Arrange MultipartContent content = new MultipartContent("related", Boundary); content.Headers.ContentType = MediaTypeHeaderValue.Parse(mediaType); content.Add(new StringContent(DefaultRootContent)); content.Add(new StringContent(OtherContent)); HttpContent contentIDContent = new StringContent(ContentIDRootContent); contentIDContent.Headers.Add("Content-ID", ContentID); content.Add(contentIDContent); MultipartRelatedStreamProvider provider = await content.ReadAsMultipartAsync(new MultipartRelatedStreamProvider()); // Act HttpContent actualRootContent = provider.RootContent; string result = await actualRootContent.ReadAsStringAsync(); // Assert if (hasStartParameter) { Assert.Equal(ContentIDRootContent, result); } else { Assert.Equal(DefaultRootContent, result); } }
private async Task <string> RootContent_PicksContent_Setup(string mediaType) { // Arrange MultipartContent content = new MultipartContent("related", Boundary); content.Headers.ContentType = MediaTypeHeaderValue.Parse(mediaType); content.Add(new StringContent(DefaultRootContent)); content.Add(new StringContent(OtherContent)); HttpContent contentIDContent = new StringContent(ContentIDRootContent); contentIDContent.Headers.Add("Content-ID", ContentID); content.Add(contentIDContent); MultipartRelatedStreamProvider provider = await content.ReadAsMultipartAsync(new MultipartRelatedStreamProvider()); // Act HttpContent actualRootContent = provider.RootContent; return(await actualRootContent.ReadAsStringAsync()); }