1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System.Linq;
6 using System.Threading.Tasks;
7 using Xunit;
8 
9 namespace System.IO.Tests
10 {
11     public class StreamAsync
12     {
CreateStream()13         protected virtual Stream CreateStream() => new MemoryStream();
14 
15         [Fact]
CopyToAsyncTest()16         public async Task CopyToAsyncTest()
17         {
18             byte[] data = Enumerable.Range(0, 1000).Select(i => (byte)(i % 256)).ToArray();
19 
20             Stream ms = CreateStream();
21             ms.Write(data, 0, data.Length);
22             ms.Position = 0;
23 
24             var ms2 = new MemoryStream();
25             await ms.CopyToAsync(ms2);
26 
27             Assert.Equal(data, ms2.ToArray());
28         }
29     }
30 }
31