public void Target_ValidChecksWithTargetChanges()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual("This is your first name.", page.nameDescriptionViewer.Description);
                Assert.IsTrue(page.nameDescriptionViewer.IsValid, "initial valid state");
                page.nameTextBox.Text = "ABCDEF!@#1";
                Assert.IsFalse(page.nameDescriptionViewer.IsValid, "invalid data");
                page.nameDescriptionViewer.Target = page.emailTextBox;
                Assert.IsTrue(page.nameDescriptionViewer.IsValid, "switch to valid target");
                page.nameDescriptionViewer.Target = page.nameTextBox;
                Assert.IsFalse(page.nameDescriptionViewer.IsValid, "switch back to invalid target");
                page.nameTextBox.Text = "ABC";
                Assert.IsTrue(page.nameDescriptionViewer.IsValid, "turned valid again");
                page.emailTextBox.Text            = "asdfkhask";
                page.nameDescriptionViewer.Target = page.emailTextBox;
                Assert.IsFalse(page.nameDescriptionViewer.IsValid, "switch to second, invalid target");
                page.nameDescriptionViewer.Target = null;
                Assert.IsTrue(page.nameDescriptionViewer.IsValid, "no target");
            });
            EnqueueTestComplete();
        }
        public void CreateInstance_NonXAML()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                DescriptionViewer dv = new DescriptionViewer();
                dv.Target            = page.nameTextBox;
            });
            EnqueueTestComplete();
        }
        public void Refresh()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                page.nameDescriptionViewer.Description = "new description";
                page.nameDescriptionViewer.Refresh();
                Assert.AreEqual("This is your first name.", page.nameDescriptionViewer.Description);
            });
            EnqueueTestComplete();
        }
        public void Target_Null()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual("This is your first name.", page.nameDescriptionViewer.Description);
                page.nameDescriptionViewer.Target = null;
                Assert.IsNull(page.nameDescriptionViewer.Description);
            });
            EnqueueTestComplete();
        }
        public void IsEnabled()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                page.nameDescriptionViewer.IsEnabled = true;
                Assert.IsTrue(page.nameDescriptionViewer.IsEnabled);
                page.nameDescriptionViewer.IsEnabled = false;
                Assert.IsFalse(page.nameDescriptionViewer.IsEnabled);
            });
            EnqueueTestComplete();
        }
        public void GlyphTemplate()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(page.nameDescriptionViewer.GlyphTemplate);
                ControlTemplate newTemplate = page.LayoutRoot.Resources["testTemplate"] as ControlTemplate;
                page.nameDescriptionViewer.GlyphTemplate = newTemplate;
                Assert.IsNotNull(page.nameDescriptionViewer.GlyphTemplate);
                Assert.AreEqual(newTemplate, page.nameDescriptionViewer.GlyphTemplate);
            });
            EnqueueTestComplete();
        }
        public void Target_ValidChecks()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual("This is your first name.", page.nameDescriptionViewer.Description);
                Assert.IsTrue(page.nameDescriptionViewer.IsValid);
                page.nameTextBox.Text = "ABCDEF!@#1";
                Assert.IsFalse(page.nameDescriptionViewer.IsValid);
                page.nameTextBox.Text = "ABC";
                Assert.IsTrue(page.nameDescriptionViewer.IsValid);
            });
            EnqueueTestComplete();
        }
        public void Target_NonVisualTreeElement()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual("This is your first name.", page.nameDescriptionViewer.Description);
                TextBox tb = new TextBox();
                Binding b  = new Binding("Email");
                tb.SetBinding(TextBox.TextProperty, b);
                tb.DataContext = page.DataContext;
                page.nameDescriptionViewer.Target = tb;
                Assert.AreEqual("Your email address", page.nameDescriptionViewer.Description);
            });
            EnqueueTestComplete();
        }
        public void Target_Unbound()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual("This is your first name.", page.nameDescriptionViewer.Description);
                Assert.IsTrue(page.nameDescriptionViewer.IsValid, "initial valid state");
                page.nameTextBox.Text = "ABCDEF!@#1";
                Assert.IsFalse(page.nameDescriptionViewer.IsValid, "invalid data");

                page.nameDescriptionViewer.Target = new TextBox();
                Assert.IsTrue(page.nameDescriptionViewer.IsValid, "no target");
                Assert.IsNull(page.nameDescriptionViewer.Description);
            });
            EnqueueTestComplete();
        }
        public void Target_WhenNotInVisualTree()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                TextBox tb = new TextBox();
                Binding b  = new Binding("Email");
                tb.SetBinding(TextBox.TextProperty, b);
                tb.DataContext = page.DataContext;

                DescriptionViewer dv = new DescriptionViewer();
                dv.Target            = tb;
                Assert.AreEqual("Your email address", dv.Description);
            });
            EnqueueTestComplete();
        }
        public void ToolTipStyle()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(page.nameDescriptionViewer.ToolTipStyle);
                Assert.AreEqual(typeof(ToolTip), page.nameDescriptionViewer.ToolTipStyle.TargetType);

                Style newStyle = page.LayoutRoot.Resources["testToopTipStyle"] as Style;
                page.nameDescriptionViewer.ToolTipStyle = newStyle;

                Assert.IsNotNull(page.nameDescriptionViewer.ToolTipStyle);
                Assert.AreEqual(newStyle, page.nameDescriptionViewer.ToolTipStyle);
            });
            EnqueueTestComplete();
        }
        public void DescriptionViewerPeer()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);
            DescriptionViewer dv = page.nameDescriptionViewer;

            this.EnqueueConditional(() => { return(page.validationSummary.Initialized); });
            this.EnqueueCallback(() =>
            {
                DescriptionViewerAutomationPeer peer = new DescriptionViewerAutomationPeer(dv);
                Assert.IsNotNull(peer);
                Assert.AreEqual(AutomationControlType.Text, peer.GetAutomationControlType());
                Assert.AreEqual("DescriptionViewer", peer.GetClassName());
                Assert.AreEqual("This is your first name.", peer.GetName());

                dv.Description = "new description";
                Assert.AreEqual(dv.Description, peer.GetName());
            });
            EnqueueTestComplete();
        }
        public void Description()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();

            this.TestPanel.Children.Add(page);

            this.EnqueueConditional(() => { return(page.nameDescriptionViewer.Initialized); });
            this.EnqueueCallback(() =>
            {
                Assert.AreEqual("This is your first name.", page.nameDescriptionViewer.Description);
                Assert.IsNotNull(page.nameDescriptionViewer.ToolTipStyle);
                Assert.AreEqual(typeof(ToolTip), page.nameDescriptionViewer.ToolTipStyle.TargetType);
                Assert.AreEqual("Your email address", page.emailDescriptionViewer.Description);

                // Overwrite description
                page.nameDescriptionViewer.Description = "new description";
                Assert.AreEqual("new description", page.nameDescriptionViewer.Description);

                // Refresh everything
                page.nameDescriptionViewer.Refresh();
                Assert.AreEqual("Your email address", page.emailDescriptionViewer.Description);
            });
            EnqueueTestComplete();
        }
        public void DescriptionViewerPeer()
        {
            DescriptionViewerTestPage page = new DescriptionViewerTestPage();
            this.TestPanel.Children.Add(page);
            DescriptionViewer dv = page.nameDescriptionViewer;

            this.EnqueueConditional(() => { return page.validationSummary.Initialized; });
            this.EnqueueCallback(() =>
            {
                DescriptionViewerAutomationPeer peer = new DescriptionViewerAutomationPeer(dv);
                Assert.IsNotNull(peer);
                Assert.AreEqual(AutomationControlType.Text, peer.GetAutomationControlType());
                Assert.AreEqual("DescriptionViewer", peer.GetClassName());
                Assert.AreEqual("This is your first name.", peer.GetName());

                dv.Description = "new description";
                Assert.AreEqual(dv.Description, peer.GetName());

            });
            EnqueueTestComplete();
        }