-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
SetOut.cs
36 lines (32 loc) · 966 Bytes
/
SetOut.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using Xunit;
[Collection(nameof(DisableParallelization))] // Console.Out is a static singleton, other tests should not be using it at the same time
public class SetOut
{
[Fact]
public static void SetOutThrowsOnNull()
{
TextWriter savedOut = Console.Out;
try
{
Assert.Throws<ArgumentNullException>(() => Console.SetOut(null));
}
finally
{
Console.SetOut(savedOut);
}
}
[Fact]
public static void SetOutReadLine()
{
Helpers.SetAndReadHelper(tw => Console.SetOut(tw), () => Console.Out, sr => sr.ReadLine());
}
[Fact]
public static void SetOutReadToEnd()
{
Helpers.SetAndReadHelper(tw => Console.SetOut(tw), () => Console.Out, sr => sr.ReadToEnd());
}
}