Skip to content

Commit

Permalink
Avoid obscuring failure by ODE thrown from Dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jul 13, 2021
1 parent 7eba2f3 commit d7d32f8
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions src/libraries/System.Console/tests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,17 @@ public static void SetAndReadHelper(Action<TextWriter> setHelper, Func<TextWrite

try
{
using (MemoryStream memStream = new MemoryStream())
{
using (StreamWriter sw = new StreamWriter(memStream))
{
setHelper(sw);
var memStream = new MemoryStream();
var sw = new StreamWriter(memStream);
setHelper(sw);

TextWriter newStream = getHelper();
TextWriter newStream = getHelper();
Assert.NotNull(newStream);
newStream.Write(TestString);
newStream.Flush();

Assert.NotNull(newStream);

newStream.Write(TestString);
newStream.Flush();

memStream.Seek(0, SeekOrigin.Begin);

using (StreamReader sr = new StreamReader(memStream))
{
string fromConsole = readHelper(sr);

Assert.Equal(TestString, fromConsole);
}
}
}
memStream.Seek(0, SeekOrigin.Begin);
Assert.Equal(TestString, readHelper(new StreamReader(memStream)));
}
finally
{
Expand Down

0 comments on commit d7d32f8

Please sign in to comment.