Exemplo n.º 1
0
        public void active_aware_view_is_notified_when_it_is_activated()
        {
            var  viewMock     = new Mock <IActiveAware>();
            bool lastIsActive = false;

            viewMock.Setup(aware => aware.SetIsActive(It.IsAny <bool>()))
            .Callback <bool>(isActive => lastIsActive = isActive)
            .Verifiable();

            viewMock.Setup(aware => aware.ToString())
            .Returns("ActiveAware");

            Invoke(
                () =>
            {
                var region = _regionManager.AttachRegion("region", _tabControl);
                region.AddView(viewMock.Object);
                region.AddView("tab2");
                region.AddView("tab3");

                region.Activate("tab2");
            });
            Wait();

            Assert.IsFalse(lastIsActive);
            var whiteTab = WhiteWindow.Get <Tab>("TabControl");
            var tab      =
                whiteTab.Pages.Find(obj => obj.Name.Contains(viewMock.Object.GetType().FullName));

            tab.Select();

            Assert.IsTrue(lastIsActive);
        }
        public MarkpadWindow NewDocument()
        {
            WhiteWindow.Get <Button>("ShowNew").Click();
            WhiteWindow.Get <Button>("NewDocument").Click();

            return(this);
        }
Exemplo n.º 3
0
        public SettingsWindow Settings()
        {
            WhiteWindow.Get <Button>("MarkpadSettings").Click();
            var automationElement = WhiteWindow.GetElement(SearchCriteria.ByAutomationId("SettingsControl"));
            var settingsControl   = new UIItemContainer(automationElement, new ProcessActionListener(automationElement));

            return(new SettingsWindow(Application, WhiteWindow, settingsControl));
        }
Exemplo n.º 4
0
        public MarkpadDocument OpenDocument(string existingDoc)
        {
            WhiteWindow.Get <Button>("ShowOpen").Click();
            WhiteWindow.Get <Button>("OpenDocument").Click();

            var openDocumentWindow = WhiteWindow.ModalWindow("Open a markdown document.");

            openDocumentWindow.Get <TextBox>(SearchCriteria.ByAutomationId("1148")).Text = existingDoc;
            openDocumentWindow.Get <Button>(SearchCriteria.ByAutomationId("1")).Click();

            WaitWhileBusy();
            return(new MarkpadDocument(this));
        }
Exemplo n.º 5
0
        public MarkpadDocument NewDocument()
        {
            var index = CurrentDocument == null ? -1 : CurrentDocument.Index;

            WhiteWindow.Get <Button>("ShowNew").Click();
            var button = WhiteWindow.Get <Button>("NewDocument");

            button.Click();

            Retry.For(() => index != CurrentDocument.Index, TimeSpan.FromSeconds(5));
            WaitWhileBusy();

            return(new MarkpadDocument(this));
        }
Exemplo n.º 6
0
        public void can_add_a_tab()
        {
            Invoke(
                () =>
            {
                var region = _regionManager.AttachRegion("region", _tabControl);
                var view   = "tab1";
                region.AddView(view);
            });

            Wait();

            var whiteTab = WhiteWindow.Get <Tab>("TabControl");

            Assert.IsNotNull(whiteTab.Pages.Find(obj => obj.Name.Contains("tab1")));
        }
Exemplo n.º 7
0
        public void can_add_a_status_element()
        {
            Invoke(
                () =>
            {
                var region = _regionManager.AttachRegion("region", _statusBar);
                var view   = "statusBarElement1";
                region.AddView(view);
            });

            Wait();

            var statusBar = WhiteWindow.Get <WPFStatusBar>("StatusBar");

            Wait();
            Assert.AreEqual(1, statusBar.Items.Count);
        }
Exemplo n.º 8
0
        public void can_add_a_tab_with_title()
        {
            Invoke(
                () =>
            {
                var region = _regionManager.AttachRegion("region", _tabControl);
                var view   = new Mock <IHaveTitle>();
                view.SetupGet(iht => iht.Title).Returns("tab1");
                region.AddView(view.Object);
            });

            Wait();

            var whiteTab = WhiteWindow.Get <Tab>("TabControl");

            Assert.IsNotNull(whiteTab.Pages.Find(
                                 obj => GetTabPageHeaderText(obj).Contains("tab1")
                                 ));
        }
Exemplo n.º 9
0
        public void synchronizes_active_item_when_user_clicks()
        {
            IRegion region = null;

            Invoke(
                () =>
            {
                region = _regionManager.AttachRegion("region",
                                                     _tabControl);
                region.AddView("tab1");
                region.AddView("tab2");
                region.AddView("tab3");
            });
            var whiteTabControl = WhiteWindow.Get <Tab>("TabControl");

            whiteTabControl.SelectTabPage("tab1");
            Wait();

            Assert.Contains("tab1", (ICollection)region.ActiveViews);
        }