mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 17:02:51 +08:00
parent
ca036f6543
commit
13ac38ed04
@ -21,7 +21,7 @@ namespace Spectre.Console.Testing
|
|||||||
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
IAnsiConsoleInput IAnsiConsole.Input => Input;
|
||||||
|
|
||||||
public FakeAnsiConsole(
|
public FakeAnsiConsole(
|
||||||
ColorSystem system,
|
ColorSystem colors,
|
||||||
AnsiSupport ansi = AnsiSupport.Yes,
|
AnsiSupport ansi = AnsiSupport.Yes,
|
||||||
int width = 80)
|
int width = 80)
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace Spectre.Console.Testing
|
|||||||
_console = factory.Create(new AnsiConsoleSettings
|
_console = factory.Create(new AnsiConsoleSettings
|
||||||
{
|
{
|
||||||
Ansi = ansi,
|
Ansi = ansi,
|
||||||
ColorSystem = (ColorSystemSupport)system,
|
ColorSystem = (ColorSystemSupport)colors,
|
||||||
Out = _writer,
|
Out = _writer,
|
||||||
Enrichment = new ProfileEnrichment
|
Enrichment = new ProfileEnrichment
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.IO;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using Spectre.Console.Testing;
|
using Spectre.Console.Testing;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@ -6,6 +7,25 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
{
|
{
|
||||||
public partial class AnsiConsoleTests
|
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
|
public sealed class TrueColor
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
|
23
src/Spectre.Console.Tests/Unit/ColorSystemTests.cs
Normal file
23
src/Spectre.Console.Tests/Unit/ColorSystemTests.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using Spectre.Console.Enrichment;
|
using Spectre.Console.Enrichment;
|
||||||
using Spectre.Console.Internal;
|
using Spectre.Console.Internal;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace Spectre.Console
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the color system to use.
|
/// Gets or sets the color system to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ColorSystemSupport ColorSystem { get; set; }
|
public ColorSystemSupport ColorSystem { get; set; } = ColorSystemSupport.Detect;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the out buffer.
|
/// Gets or sets the out buffer.
|
||||||
|
@ -8,31 +8,31 @@ namespace Spectre.Console
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to detect the color system.
|
/// Try to detect the color system.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Detect = 0,
|
Detect = -1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// No colors.
|
/// No colors.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
NoColors = 1,
|
NoColors = 0,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Legacy, 3-bit mode.
|
/// Legacy, 3-bit mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Legacy = 2,
|
Legacy = 1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Standard, 4-bit mode.
|
/// Standard, 4-bit mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Standard = 3,
|
Standard = 2,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 8-bit mode.
|
/// 8-bit mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
EightBit = 4,
|
EightBit = 3,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 24-bit mode.
|
/// 24-bit mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
TrueColor = 5,
|
TrueColor = 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user