inital impl

This commit is contained in:
Charlie Kindel
2022-11-07 18:21:32 -07:00
parent eb080188c4
commit cbbeb404a7
2 changed files with 41 additions and 14 deletions

View File

@@ -5,9 +5,9 @@ using Xunit;
namespace Terminal.Gui.Core {
public class ClipboardTests {
[Fact]
[AutoInitShutdown]
public void Contents_Gets_Sets ()
{
Application.Init (new FakeDriver (useFakeClipboard: false), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var clipText = "This is a clipboard unit test.";
Clipboard.Contents = clipText;
@@ -16,23 +16,25 @@ namespace Terminal.Gui.Core {
Application.Run ();
Assert.Equal (clipText, Clipboard.Contents);
Application.Shutdown ();
}
[Fact]
[AutoInitShutdown]
public void IsSupported_Get ()
{
Application.Init (new FakeDriver (useFakeClipboard: false), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
if (Clipboard.IsSupported) {
Assert.True (Clipboard.IsSupported);
} else {
Assert.False (Clipboard.IsSupported);
}
Application.Shutdown ();
}
[Fact]
[AutoInitShutdown]
public void TryGetClipboardData_Gets_From_OS_Clipboard ()
{
Application.Init (new FakeDriver (useFakeClipboard: false), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var clipText = "Trying to get from the OS clipboard.";
Clipboard.Contents = clipText;
@@ -47,12 +49,13 @@ namespace Terminal.Gui.Core {
Assert.False (Clipboard.TryGetClipboardData (out string result));
Assert.NotEqual (clipText, result);
}
Application.Shutdown ();
}
[Fact]
[AutoInitShutdown]
public void TrySetClipboardData_Sets_The_OS_Clipboard ()
{
Application.Init (new FakeDriver (useFakeClipboard: false), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var clipText = "Trying to set the OS clipboard.";
if (Clipboard.IsSupported) {
Assert.True (Clipboard.TrySetClipboardData (clipText));
@@ -69,12 +72,13 @@ namespace Terminal.Gui.Core {
} else {
Assert.NotEqual (clipText, Clipboard.Contents);
}
Application.Shutdown ();
}
[Fact]
[AutoInitShutdown]
public void Contents_Gets_From_OS_Clipboard ()
{
Application.Init (new FakeDriver (useFakeClipboard: false), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var clipText = "This is a clipboard unit test to get clipboard from OS.";
var exit = false;
var getClipText = "";
@@ -189,12 +193,13 @@ namespace Terminal.Gui.Core {
if (!exit) {
Assert.Equal (clipText, getClipText);
}
Application.Shutdown ();
}
[Fact]
[AutoInitShutdown]
public void Contents_Sets_The_OS_Clipboard ()
{
Application.Init (new FakeDriver (useFakeClipboard: false), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var clipText = "This is a clipboard unit test to set the OS clipboard.";
var clipReadText = "";
var exit = false;
@@ -274,6 +279,7 @@ namespace Terminal.Gui.Core {
if (!exit) {
Assert.Equal (clipText, clipReadText);
}
Application.Shutdown ();
}
bool Is_WSL_Platform ()