Exemplo n.º 1
0
        public void ClipBoardUpdateEventsAreCorrectlyProcessed()
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardConfig      = Mock.Get((IClipboardConfiguration)mockObjects[nameof(IClipboardConfiguration)]);
            var sharpClipboardMapper = Mock.Get((ISharpClipboardMapper)mockObjects[nameof(ISharpClipboardMapper)]);
            var textCopyMapper       = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            string[] entries = new[] { string.Empty };
            clipboardManager.ClipboardTextUpdateReceived += (s, e) =>
            {
                entries = e.ClipboardEntries;
            };

            sharpClipboardMapper.Raise(
                x => x.ClipboardChanged += null,
                this,
                new ClipboardChangedEventArgs(
                    applicationName: "testApp",
                    clipboardContent: "testContent",
                    contentType: SharpClipboard.ContentTypes.Text));

            Assert.True(entries.Length == 1);
            Assert.Equal("testContent", entries[0]);
        }
Exemplo n.º 2
0
        public void ProcessingMultipleRowsAndTrimmingSucceeds()
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardConfig      = Mock.Get((IClipboardConfiguration)mockObjects[nameof(IClipboardConfiguration)]);
            var sharpClipboardMapper = Mock.Get((ISharpClipboardMapper)mockObjects[nameof(ISharpClipboardMapper)]);
            var textCopyMapper       = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            clipboardConfig.SetupGet(x => x.AutomaticTrim).Returns(true);
            clipboardConfig.SetupGet(x => x.ProcessMultipleRows).Returns(true);
            clipboardConfig.SetupGet(x => x.MaxProcessedRows).Returns(100);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            string[] entries = new[] { string.Empty };
            clipboardManager.ClipboardTextUpdateReceived += (s, e) =>
            {
                entries = e.ClipboardEntries;
            };

            sharpClipboardMapper.Raise(
                x => x.ClipboardChanged += null,
                this,
                new ClipboardChangedEventArgs(
                    applicationName: "testApp",
                    clipboardContent: " testContent " + Environment.NewLine + " testContent2 ",
                    contentType: SharpClipboard.ContentTypes.Text));

            Assert.True(entries.Length == 2);
            Assert.Equal("testContent", entries[0]);
            Assert.Equal("testContent2", entries[1]);
        }
Exemplo n.º 3
0
        public void CorrectNumberOfEntriesIsPublished(string testText, bool multipleRows, int maxMultipleRows, int expectedEntriesCount)
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardConfig      = Mock.Get((IClipboardConfiguration)mockObjects[nameof(IClipboardConfiguration)]);
            var sharpClipboardMapper = Mock.Get((ISharpClipboardMapper)mockObjects[nameof(ISharpClipboardMapper)]);
            var textCopyMapper       = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            clipboardConfig.SetupGet(x => x.MaxProcessedRows).Returns(maxMultipleRows);
            clipboardConfig.SetupGet(x => x.ProcessMultipleRows).Returns(multipleRows);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            clipboardManager.AppName = "testApp2";
            var eventCorrectRaised = false;

            clipboardManager.ClipboardTextUpdateReceived += (s, e) =>
            {
                eventCorrectRaised = e.ClipboardEntries.Length == expectedEntriesCount;
            };

            sharpClipboardMapper.Raise(
                x => x.ClipboardChanged += null,
                this,
                new ClipboardChangedEventArgs(
                    applicationName: "testApp",
                    clipboardContent: testText,
                    contentType: SharpClipboard.ContentTypes.Text));

            Assert.True(eventCorrectRaised);
        }
Exemplo n.º 4
0
        public void TextIsCopiedToClipboard()
        {
            var mockObjects    = MockFactories.GetMockObjects();
            var textCopyMapper = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);

            clipboardManager.CopyTextToClipboard("test");

            textCopyMapper.Verify(x => x.SetText(It.IsAny <string>()), Times.Once);
        }
Exemplo n.º 5
0
        public void ClipboardEventsAreNotFiredWhenContentIsNotText()
        {
            var mockObjects          = MockFactories.GetMockObjects();
            var clipboardConfig      = Mock.Get((IClipboardConfiguration)mockObjects[nameof(IClipboardConfiguration)]);
            var sharpClipboardMapper = Mock.Get((ISharpClipboardMapper)mockObjects[nameof(ISharpClipboardMapper)]);
            var textCopyMapper       = Mock.Get((ITextCopyMapper)mockObjects[nameof(ITextCopyMapper)]);

            var clipboardManager = MockFactories.ClipboardManagerFactory(mockObjects);
            var eventRaised      = false;

            clipboardManager.ClipboardTextUpdateReceived += (s, e) => { eventRaised = true; };
            sharpClipboardMapper.Raise(
                x => x.ClipboardChanged += null,
                this,
                new ClipboardChangedEventArgs(
                    applicationName: "testApp",
                    clipboardContent: "testContent",
                    contentType: SharpClipboard.ContentTypes.Other));

            Assert.False(eventRaised);
        }