public async Task TestClipboardMonitor_Text() { const string testString = "Dapplo.Windows.Tests.ClipboardTests"; bool hasNewContent = false; var subscription = ClipboardMonitor.OnUpdate.Where(clipboard => clipboard.Formats.Contains("TEST_FORMAT")).Subscribe(clipboard => { Log.Debug().WriteLine("Detected change {0}", string.Join(",", clipboard.Formats)); Log.Debug().WriteLine("Owner {0}", clipboard.OwnerHandle); Log.Debug().WriteLine("Sequence {0}", clipboard.Id); hasNewContent = true; }); using (ClipboardNative.Lock()) { ClipboardNative.Clear(); ClipboardNative.SetAsUnicodeString(testString, "TEST_FORMAT"); } await Task.Delay(1000); subscription.Dispose(); // Doesn't work on AppVeyor!! Assert.True(hasNewContent); }
public async Task TestClipboardStore_String() { const string testString = "Dapplo.Windows.Tests.ClipboardTests"; using (ClipboardNative.Lock()) { ClipboardNative.Clear(); ClipboardNative.SetAsUnicodeString(testString); } await Task.Delay(1000); using (ClipboardNative.Lock()) { Assert.Equal(testString, ClipboardNative.GetAsUnicodeString()); } }
public void TestClipboard_RegisterFormat() { string format = "DAPPLO.DOPY" + ClipboardNative.SequenceNumber; // Register the format var id1 = ClipboardNative.RegisterFormat(format); // Register the format again var id2 = ClipboardNative.RegisterFormat(format); Assert.Equal(id1, id2); // Make sure it works using (ClipboardNative.Lock()) { ClipboardNative.Clear(); ClipboardNative.SetAsUnicodeString("Blub", format); } }