mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using System;
|
|
using Shouldly;
|
|
using Spectre.Console.Composition;
|
|
using Xunit;
|
|
|
|
namespace Spectre.Console.Tests.Unit
|
|
{
|
|
public sealed class BorderTests
|
|
{
|
|
public sealed class TheGetBorderMethod
|
|
{
|
|
[Theory]
|
|
[InlineData(BorderKind.None, false, typeof(NoBorder))]
|
|
[InlineData(BorderKind.Ascii, false, typeof(AsciiBorder))]
|
|
[InlineData(BorderKind.Square, false, typeof(SquareBorder))]
|
|
[InlineData(BorderKind.Rounded, false, typeof(RoundedBorder))]
|
|
[InlineData(BorderKind.None, true, typeof(NoBorder))]
|
|
[InlineData(BorderKind.Ascii, true, typeof(AsciiBorder))]
|
|
[InlineData(BorderKind.Square, true, typeof(SquareBorder))]
|
|
[InlineData(BorderKind.Rounded, true, typeof(SquareBorder))]
|
|
public void Should_Return_Correct_Border_For_Specified_Kind(BorderKind kind, bool safe, Type expected)
|
|
{
|
|
// Given, When
|
|
var result = Border.GetBorder(kind, safe);
|
|
|
|
// Then
|
|
result.ShouldBeOfType(expected);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_Throw_If_Unknown_Border_Kind_Is_Specified()
|
|
{
|
|
// Given, When
|
|
var result = Record.Exception(() => Border.GetBorder((BorderKind)int.MaxValue, false));
|
|
|
|
// Then
|
|
result.ShouldBeOfType<InvalidOperationException>();
|
|
result.Message.ShouldBe("Unknown border kind");
|
|
}
|
|
}
|
|
}
|
|
}
|