namespace Terminal.Gui.Drivers; /// /// Implements a fake clipboard for testing purposes. /// public class FakeClipboard : ClipboardBase { /// /// Gets or sets an exception to be thrown by clipboard operations. /// public Exception? FakeException { get; set; } private readonly bool _isSupportedAlwaysFalse; private string _contents = string.Empty; /// /// Constructs a new instance of . /// /// /// public FakeClipboard ( bool fakeClipboardThrowsNotSupportedException = false, bool isSupportedAlwaysFalse = false ) { _isSupportedAlwaysFalse = isSupportedAlwaysFalse; if (fakeClipboardThrowsNotSupportedException) { FakeException = new NotSupportedException ("Fake clipboard exception"); } } /// public override bool IsSupported => !_isSupportedAlwaysFalse; /// protected override string GetClipboardDataImpl () { if (FakeException is { }) { throw FakeException; } return _contents; } /// protected override void SetClipboardDataImpl (string? text) { if (FakeException is { }) { throw FakeException; } _contents = text ?? throw new ArgumentNullException (nameof (text)); } }