-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathColorConsoleTests.cs
47 lines (40 loc) · 1.55 KB
/
ColorConsoleTests.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
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
using System;
using NUnit.Framework;
namespace NUnit.TextDisplay
{
[TestFixture, Parallelizable(ParallelScope.None)]
public class ColorConsoleTests
{
private ColorStyle _testStyle;
[SetUp]
public void SetUp()
{
// Find a test color that is different than the console color
if (Console.ForegroundColor != ColorConsole.GetColor( ColorStyle.Error ))
_testStyle = ColorStyle.Error;
else if (Console.ForegroundColor != ColorConsole.GetColor( ColorStyle.Pass ))
_testStyle = ColorStyle.Pass;
else
Assert.Inconclusive("Could not find a color to test with");
// Set to an unknown, unlikely color so that we can test for change
Console.ForegroundColor = ConsoleColor.Magenta;
Assume.That(Console.ForegroundColor, Is.EqualTo(ConsoleColor.Magenta), "Color tests cannot be run because the current console does not support color");
}
[TearDown]
public void TearDown()
{
Console.ResetColor();
}
[Test]
public void TestConstructor()
{
ConsoleColor expected = ColorConsole.GetColor(_testStyle);
using(new ColorConsole(_testStyle))
{
Assert.That(Console.ForegroundColor, Is.EqualTo(expected));
}
Assert.That( Console.ForegroundColor, Is.Not.EqualTo(expected) );
}
}
}