public async Task TestReadAsync() { using (var original = new MemoryStream()) { using (var file = File.OpenRead("../../TestData/encoders/photo.jpg")) file.CopyTo(original, 4096); using (var decoded = new MemoryStream()) { using (var file = File.OpenRead("../../TestData/encoders/photo.b64")) { using (var filtered = new FilteredStream(file)) { filtered.Add(DecoderFilter.Create(ContentEncoding.Base64)); await filtered.CopyToAsync(decoded, 4096); } } var buf0 = original.GetBuffer(); var buf1 = decoded.GetBuffer(); int n = (int)original.Length; Assert.AreEqual(original.Length, decoded.Length, "Decoded length is incorrect."); for (int i = 0; i < n; i++) { Assert.AreEqual(buf0[i], buf1[i], "The byte at offset {0} does not match.", i); } } } }