public async Task BufferedRead() { // Arrange. Specifically use the base class with async signatures. MediaTypeFormatter formatter = new MockBufferedMediaTypeFormatter(); byte[] expectedBytes = ExpectedSupportedEncodings.ElementAt(0).GetBytes(TestData); MemoryStream input = new MemoryStream(expectedBytes); // Act. Call the async signature. object result = await formatter.ReadFromStreamAsync(TestData.GetType(), input, null, null); // Assert Assert.Equal(TestData, result); }
public async Task BufferedWrite() { // Arrange. Specifically use the base class with async signatures. MediaTypeFormatter formatter = new MockBufferedMediaTypeFormatter(); MemoryStream output = new MemoryStream(); // Act. Call the async signature. await formatter.WriteToStreamAsync(TestData.GetType(), TestData, output, null, null); // Assert byte[] expectedBytes = ExpectedSupportedEncodings.ElementAt(0).GetBytes(TestData); byte[] actualBytes = output.ToArray(); Assert.Equal(expectedBytes, actualBytes); }
public void SupportEncoding_DefaultSupportedEncodings() { TFormatter formatter = CreateFormatter(); Assert.True(ExpectedSupportedEncodings.SequenceEqual(formatter.SupportedEncodings)); }