Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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());
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }