Skip to content

Commit

Permalink
Include derived types of ArgumentException in DataStreamTest when rea…
Browse files Browse the repository at this point in the history
…ding past end of stream (#1472)

1404 $ 1405
  • Loading branch information
DavoudEshtehari committed Jan 14, 2022
1 parent 768b58b commit 8b4c902
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1555,8 +1555,14 @@ private static void ReadStream(string connectionString)
DataTestUtility.AssertThrowsWrapper<ArgumentNullException>(() => stream.Read(null, 0, 1));
DataTestUtility.AssertThrowsWrapper<ArgumentOutOfRangeException>(() => stream.Read(buffer, -1, 2));
DataTestUtility.AssertThrowsWrapper<ArgumentOutOfRangeException>(() => stream.Read(buffer, 2, -1));
DataTestUtility.AssertThrowsWrapper<ArgumentException>(() => stream.Read(buffer, buffer.Length, buffer.Length));
DataTestUtility.AssertThrowsWrapper<ArgumentException>(() => stream.Read(buffer, int.MaxValue, int.MaxValue));

// ArgumentException is thrown in net5 and earlier. ArgumentOutOfRangeException in net6 and later
ArgumentException ex = Assert.ThrowsAny<ArgumentException>(() => stream.Read(buffer, buffer.Length, buffer.Length));
Assert.True(ex.GetType() == typeof(ArgumentException) || ex.GetType() == typeof(ArgumentOutOfRangeException),
"Expected: ArgumentException in net5 and earlier. ArgumentOutOfRangeException in net6 and later.");
ex = Assert.ThrowsAny<ArgumentException>(() => stream.Read(buffer, int.MaxValue, int.MaxValue));
Assert.True(ex.GetType() == typeof(ArgumentException) || ex.GetType() == typeof(ArgumentOutOfRangeException),
"Expected: ArgumentException in net5 and earlier. ArgumentOutOfRangeException in net6 and later.");
}

// Once Reader is closed
Expand Down

0 comments on commit 8b4c902

Please sign in to comment.