コード例 #1
0
        public void CopiesTextCorrectly()
        {
            try
            {
                CodeSample           codeSampleNormal = (CodeSample)ControlsTestPage.Instance.FindName("CodeSampleNormal");
                ButtonAutomationPeer copyButton       = new ButtonAutomationPeer((Button)codeSampleNormal.FindName("CopyButton"));

                copyButton.Invoke();
                Assert.AreEqual("Code", GetClipBoardText());

                CodeSample codeSampleHighlightingEnabled = (CodeSample)ControlsTestPage.Instance.FindName("CodeSampleWithHighlighting");
                copyButton = new ButtonAutomationPeer((Button)codeSampleHighlightingEnabled.FindName("CopyButton"));

                copyButton.Invoke();

                Assert.AreEqual("<Code />", GetClipBoardText());
            }
            catch (UnauthorizedAccessException)
            {
                // Pasting to clipboard is not allowed while app is in background
#pragma warning disable CA1303 // Do not pass literals as localized parameters
                Console.WriteLine("Test CopiesTextCorrectly was not run as app is not in foreground");
#pragma warning restore CA1303 // Do not pass literals as localized parameters
            }
        }
コード例 #2
0
        public void VerifyRenderedText()
        {
            CodeSample    codeSampleNormal = (CodeSample)ControlsTestPage.Instance.FindName("CodeSampleNormal");
            RichTextBlock codeText         = (RichTextBlock)codeSampleNormal.FindName("CodeBlock");

            codeText.SelectAll();

            Assert.AreEqual("Code", codeText.SelectedText);

            CodeSample codeSampleHighlightingEnabled = (CodeSample)ControlsTestPage.Instance.FindName("CodeSampleWithHighlighting");

            codeText = (RichTextBlock)codeSampleHighlightingEnabled.FindName("CodeBlock");
            codeText.SelectAll();

            Assert.AreEqual("<Code />", codeText.SelectedText);
        }