should empty first
MODIFY
Tests/ClipboardTests.cs
Tests/ClipboardTests.cs
@@ -15,12 +15,11 @@ public class ClipboardTests
static void Verify(string expected)
{
+ TextCopy.Clipboard.SetText(expected);
+
Exception caught = null;
var t = new Thread(() =>
{
- Clipboard.Clear();
- TextCopy.Clipboard.SetText(expected);
-
try
{
var actual = Clipboard.GetText();

MODIFY
TextCopy/WindowsClipboard.cs
TextCopy/WindowsClipboard.cs
@@ -11,6 +11,7 @@ static class WindowsClipboard
throw new Win32Exception(Marshal.GetLastWin32Error());
}
+ EmptyClipboard();
try
{
var bytes = ((uint) text.Length + 1) * 2;
@@ -96,6 +97,9 @@ static class WindowsClipboard
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetClipboardData(uint uFormat, IntPtr data);
+ [DllImport("user32.dll")]
+ static extern bool EmptyClipboard();
+
const uint CF_UNICODETEXT = 13;
const uint GMEM_MOVABLE = 0x0002;
}
\ No newline at end of file

should empty first