diff --git a/src/Spectre.Console.Testing/Fakes/FakeAnsiConsole.cs b/src/Spectre.Console.Testing/Fakes/FakeAnsiConsole.cs index a9b09c1..da1f36d 100644 --- a/src/Spectre.Console.Testing/Fakes/FakeAnsiConsole.cs +++ b/src/Spectre.Console.Testing/Fakes/FakeAnsiConsole.cs @@ -21,7 +21,7 @@ namespace Spectre.Console.Testing IAnsiConsoleInput IAnsiConsole.Input => Input; public FakeAnsiConsole( - ColorSystem system, + ColorSystem colors, AnsiSupport ansi = AnsiSupport.Yes, int width = 80) { @@ -32,7 +32,7 @@ namespace Spectre.Console.Testing _console = factory.Create(new AnsiConsoleSettings { Ansi = ansi, - ColorSystem = (ColorSystemSupport)system, + ColorSystem = (ColorSystemSupport)colors, Out = _writer, Enrichment = new ProfileEnrichment { diff --git a/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Colors.cs b/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Colors.cs index 8fc9970..a07c1f5 100644 --- a/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Colors.cs +++ b/src/Spectre.Console.Tests/Unit/AnsiConsoleTests.Colors.cs @@ -1,3 +1,4 @@ +using System.IO; using Shouldly; using Spectre.Console.Testing; using Xunit; @@ -6,6 +7,25 @@ namespace Spectre.Console.Tests.Unit { public partial class AnsiConsoleTests { + [Theory] + [InlineData(ColorSystemSupport.NoColors, ColorSystem.NoColors)] + [InlineData(ColorSystemSupport.Legacy, ColorSystem.Legacy)] + [InlineData(ColorSystemSupport.Standard, ColorSystem.Standard)] + [InlineData(ColorSystemSupport.EightBit, ColorSystem.EightBit)] + [InlineData(ColorSystemSupport.TrueColor, ColorSystem.TrueColor)] + public void Should_Create_Console_With_Requested_ColorSystem(ColorSystemSupport requested, ColorSystem expected) + { + // Given, When + var console = AnsiConsole.Create(new AnsiConsoleSettings + { + ColorSystem = requested, + Out = new StringWriter(), + }); + + // Then + console.Profile.ColorSystem.ShouldBe(expected); + } + public sealed class TrueColor { [Theory] diff --git a/src/Spectre.Console.Tests/Unit/ColorSystemTests.cs b/src/Spectre.Console.Tests/Unit/ColorSystemTests.cs new file mode 100644 index 0000000..a74befa --- /dev/null +++ b/src/Spectre.Console.Tests/Unit/ColorSystemTests.cs @@ -0,0 +1,23 @@ +using Shouldly; +using Xunit; + +namespace Spectre.Console.Tests.Unit +{ + public sealed class ColorSystemTests + { + [Theory] + [InlineData(ColorSystem.NoColors, ColorSystemSupport.NoColors)] + [InlineData(ColorSystem.Legacy, ColorSystemSupport.Legacy)] + [InlineData(ColorSystem.Standard, ColorSystemSupport.Standard)] + [InlineData(ColorSystem.EightBit, ColorSystemSupport.EightBit)] + [InlineData(ColorSystem.TrueColor, ColorSystemSupport.TrueColor)] + public void Should_Be_Analog_To_ColorSystemSupport(ColorSystem colors, ColorSystemSupport support) + { + // Given, When + var result = (int)colors; + + // Then + result.ShouldBe((int)support); + } + } +} diff --git a/src/Spectre.Console/AnsiConsoleFactory.cs b/src/Spectre.Console/AnsiConsoleFactory.cs index e2612f5..43194c4 100644 --- a/src/Spectre.Console/AnsiConsoleFactory.cs +++ b/src/Spectre.Console/AnsiConsoleFactory.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using System.Text; using Spectre.Console.Enrichment; using Spectre.Console.Internal; diff --git a/src/Spectre.Console/AnsiConsoleSettings.cs b/src/Spectre.Console/AnsiConsoleSettings.cs index e847481..6fee233 100644 --- a/src/Spectre.Console/AnsiConsoleSettings.cs +++ b/src/Spectre.Console/AnsiConsoleSettings.cs @@ -17,7 +17,7 @@ namespace Spectre.Console /// /// Gets or sets the color system to use. /// - public ColorSystemSupport ColorSystem { get; set; } + public ColorSystemSupport ColorSystem { get; set; } = ColorSystemSupport.Detect; /// /// Gets or sets the out buffer. diff --git a/src/Spectre.Console/ColorSystemSupport.cs b/src/Spectre.Console/ColorSystemSupport.cs index 37f4aa5..cdff656 100644 --- a/src/Spectre.Console/ColorSystemSupport.cs +++ b/src/Spectre.Console/ColorSystemSupport.cs @@ -8,31 +8,31 @@ namespace Spectre.Console /// /// Try to detect the color system. /// - Detect = 0, + Detect = -1, /// /// No colors. /// - NoColors = 1, + NoColors = 0, /// /// Legacy, 3-bit mode. /// - Legacy = 2, + Legacy = 1, /// /// Standard, 4-bit mode. /// - Standard = 3, + Standard = 2, /// /// 8-bit mode. /// - EightBit = 4, + EightBit = 3, /// /// 24-bit mode. /// - TrueColor = 5, + TrueColor = 4, } }