Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -50,7 +50,7 @@ namespace System.IO.Tests
using (BufferedStream stream = new BufferedStream(new MemoryStream()))
{
byte[] array = new byte[10];
Assert.Throws<ArgumentNullException>("array", () => stream.Read(null, 1, 1));
AssertExtensions.Throws<ArgumentNullException>("array", () => stream.Read(null, 1, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Read(array, -1, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Read(array, 1, -1));
Assert.Throws<ArgumentException>(() => stream.Read(array, 9, 2));
@@ -63,7 +63,7 @@ namespace System.IO.Tests
using (BufferedStream stream = new BufferedStream(new MemoryStream()))
{
byte[] array = new byte[10];
Assert.Throws<ArgumentNullException>("array", () => stream.Write(null, 1, 1));
AssertExtensions.Throws<ArgumentNullException>("array", () => stream.Write(null, 1, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Write(array, -1, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => stream.Write(array, 1, -1));
Assert.Throws<ArgumentException>(() => stream.Write(array, 9, 2));
@@ -119,11 +119,11 @@ namespace System.IO.Tests
using (var s = new BufferedStream(new MemoryStream()))
{
// Null destination
Assert.Throws<ArgumentNullException>("destination", () => { s.CopyToAsync(null); });
AssertExtensions.Throws<ArgumentNullException>("destination", () => { s.CopyToAsync(null); });
// Buffer size out-of-range
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), 0); });
Assert.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), -1, CancellationToken.None); });
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), 0); });
AssertExtensions.Throws<ArgumentOutOfRangeException>("bufferSize", () => { s.CopyToAsync(new MemoryStream(), -1, CancellationToken.None); });
// Copying to non-writable stream
Assert.Throws<NotSupportedException>(() => { s.CopyToAsync(new WrappedMemoryStream(canRead: true, canWrite: false, canSeek: true)); });

View File

@@ -278,4 +278,31 @@ namespace System.IO.Tests
throw new InvalidOperationException("Exception from FlushAsync");
}
}
public class BufferedStream_NS17
{
protected Stream CreateStream()
{
return new BufferedStream(new MemoryStream());
}
public void EndCallback(IAsyncResult ar)
{ }
[Fact]
public void BeginEndReadTest()
{
Stream stream = CreateStream();
IAsyncResult result = stream.BeginRead(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
stream.EndRead(result);
}
[Fact]
public void BeginEndWriteTest()
{
Stream stream = CreateStream();
IAsyncResult result = stream.BeginWrite(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
stream.EndWrite(result);
}
}
}

View File

@@ -1,40 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace System.IO.Tests
{
public class BufferedStream_NS17
{
protected Stream CreateStream()
{
return new BufferedStream(new MemoryStream());
}
public void EndCallback(IAsyncResult ar)
{ }
[Fact]
public void BeginEndReadTest()
{
Stream stream = CreateStream();
IAsyncResult result = stream.BeginRead(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
stream.EndRead(result);
}
[Fact]
public void BeginEndWriteTest()
{
Stream stream = CreateStream();
IAsyncResult result = stream.BeginWrite(new byte[1], 0, 1, new AsyncCallback(EndCallback), new object());
stream.EndWrite(result);
}
}
}