mirror of
https://github.com/spectreconsole/examples.git
synced 2025-10-25 15:19:18 +00:00
43 lines
951 B
C#
43 lines
951 B
C#
using Spectre.Console;
|
|
using Spectre.Console.Testing;
|
|
|
|
namespace Testing;
|
|
|
|
[TestClass]
|
|
public class ConsoleTests
|
|
{
|
|
[TestMethod]
|
|
public void Should_Render_Panel()
|
|
{
|
|
// Given
|
|
var console = new TestConsole();
|
|
|
|
// When
|
|
console.Write(new Panel(new Text("Hello World")));
|
|
|
|
// Then
|
|
Assert.AreEqual(console.Output, """"
|
|
┌─────────────┐
|
|
│ Hello World │
|
|
└─────────────┘
|
|
|
|
"""");
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Should_Select_Orange()
|
|
{
|
|
// Given
|
|
var console = new TestConsole();
|
|
console.Input.PushTextWithEnter("Orange");
|
|
|
|
// When
|
|
console.Prompt(
|
|
new TextPrompt<string>("Favorite fruit?")
|
|
.AddChoice("Banana")
|
|
.AddChoice("Orange"));
|
|
|
|
// Then
|
|
Assert.AreEqual(console.Output, "Favorite fruit? [Banana/Orange]: Orange\n");
|
|
}
|
|
} |