Ejemplo n.º 1
0
        public void ShouldBeEmpty()
        {
            _universe.Window.Find <Tab>(FindBy.WpfText("Basket")).Select();
            var basketContents = _universe.Window.Find <GridView>("basketOutput");

            Assert.IsTrue(basketContents.IsEmpty());
        }
Ejemplo n.º 2
0
        public void ShouldContain(string name, double price)
        {
            _universe.Window.Find <Tab>(FindBy.WpfText("Basket")).Select();
            var basketContents = _universe.Window.Find <GridView>("basketOutput");

            Assert.True(basketContents.ContainsRow(name, price.ToString("0.00")));
        }
Ejemplo n.º 3
0
        public void ShouldDetermineIfItContainsARowWithTheGivenHeaderAndPropertyCondition()
        {
            _window = LaunchPetShopWindow();
            _window.Find <Tab>(FindBy.WpfText("History")).Select();
            var gridView = _window.Find <GridView>("lastPetsOutput");

            Assert.True(gridView.ContainsRow("Name", FindBy.WpfText("Dancer")));
        }
Ejemplo n.º 4
0
        public void ShouldProvideItsTextByCell()
        {
            _window = LaunchPetShopWindow();
            _window.Find <Tab>(FindBy.WpfText("History")).Select();
            var gridView = _window.Find <GridView>("lastPetsOutput");

            Assert.AreEqual("Dancer", gridView.TextAt(0, 2));
        }
Ejemplo n.º 5
0
        public void ShouldBeAbleToRetrieveTheRowIndexForARowWithTheGivenHeaderAndPropertyCondition()
        {
            _window = LaunchPetShopWindow();
            _window.Find <Tab>(FindBy.WpfText("History")).Select();
            var gridView = _window.Find <GridView>("lastPetsOutput");

            Assert.AreEqual(2, gridView.IndexOf("Name", FindBy.WpfText("Dancer")));
        }
Ejemplo n.º 6
0
        public void ShouldAllowTextToBeRetrievedFromBlock()
        {
            Window window = LaunchPetShopWindow();

            window.Find <Tab>(FindBy.WpfText("History")).Select();
            var block = window.Find <TextBlock>("historyDescription");

            Assert.AreEqual("A short summary of what has already happened:", block.Text);
        }
Ejemplo n.º 7
0
        public void ShouldScrollUntilCheckIsTrue()
        {
            var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("Accessories"));

            tab.Select();
            var scrollViewer = tab.Find <ScrollViewer>(new PropertyCondition(AutomationElement.IsScrollPatternAvailableProperty, true));

            scrollViewer.ScrollDown(s => s.Contains(FindBy.WpfText("Flea powder")), s => Assert.Fail("Should have found row"));
        }
Ejemplo n.º 8
0
        public void ShouldProvideAContextMenuIfItExists()
        {
            var window      = LaunchPetShopWindow();
            var label       = window.Find <Label>(FindBy.WpfText("(Right-click here to copy an existing pet's details)"));
            var contextMenu = label
                              .InvokeContextMenu(FindBy.WpfName("copyPetMenu"));

            contextMenu.Select(contextMenu.Items[0]);
        }
Ejemplo n.º 9
0
        public void ShouldBeAbleToRetrieveTheElementReferencedByColumnAndRow()
        {
            _window = LaunchPetShopWindow();
            _window.Find <Tab>(FindBy.WpfText("History")).Select();
            var gridView = _window.Find <GridView>("lastPetsOutput");
            var cell     = gridView.ElementAt <Label>(0, 2);

            Assert.AreEqual("Dancer", cell.Text);
        }
Ejemplo n.º 10
0
        public void ShouldAllowTabToBeSelected()
        {
            var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("History"));

            Assert.False(tab.HasFocus());

            tab.Select();
            Assert.True(tab.HasFocus());
        }
Ejemplo n.º 11
0
        public void ShouldBeAbleToRetrieveTheElementReferencedByARowWithHeaderMatchingAPropertyConditionFromSecondHeader()
        {
            _window = LaunchPetShopWindow();
            _window.Find <Tab>(FindBy.WpfText("History")).Select();
            var gridView = _window.Find <GridView>("lastPetsOutput");
            var cell     = gridView.FindReferencedElement <Label>("Name", FindBy.WpfText("Dancer"), "Price");

            Assert.AreEqual(54.00.ToString("0.00"), cell.Text);
        }
Ejemplo n.º 12
0
        public void ShouldProvideAllAvailableText()
        {
            _window = LaunchPetShopWindow();
            _window.Find <Tab>(FindBy.WpfText("History")).Select();
            var gridView = _window.Find <GridView>("lastPetsOutput");

            Assert.AreEqual(3 * 4, gridView.AllText.Length);
            Assert.AreEqual("Dancer", gridView.AllText[2, 0]);
        }
Ejemplo n.º 13
0
        public void ShouldDetermineIfItContainsARow()
        {
            _window = LaunchPetShopWindow();
            _window.Find <Tab>(FindBy.WpfText("History")).Select();
            var gridView = _window.Find <GridView>("lastPetsOutput");

            Assert.IsTrue(gridView.ContainsRow("Dancer", "Rabbit", 54.00.ToString("0.00"), "False"));
            Assert.IsFalse(gridView.ContainsRow("Prancer", "Reindeer", 30.00.ToString("0.00"), "False"));
        }
Ejemplo n.º 14
0
        public void ShouldAllowTextToBeEnteredIntoTheTextBox()
        {
            Window window = LaunchPetShopWindow();

            window.Find <Tab>(FindBy.WpfText("History")).Select();
            var box = window.Find <RichTextBox>("historyInput");

            box.Text = "Gooseberry Bear";
            Assert.AreEqual("Gooseberry Bear", box.Text);
        }
Ejemplo n.º 15
0
        public void ShouldHandleFailureToScroll()
        {
            var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("Accessories"));

            tab.Select();
            var scrollViewer = tab.Find <ScrollViewer>(new PropertyCondition(AutomationElement.IsScrollPatternAvailableProperty, true));
            var complained   = false;

            scrollViewer.ScrollDown(s => false, s => complained = true);
            Assert.True(complained, "Should have handled failure to scroll");
        }
Ejemplo n.º 16
0
        public void ShouldPassFailureHandlerToChildContainers()
        {
            var container  = LaunchPetShopWindow();
            var complained = true;

            container.HandlerForFailingToFind = s => complained = true;

            var childContainer = container.Find <Tab>(FindBy.WpfText("Basket"));

            childContainer.Find <ComboBox>("Unlikely!");
            Assert.True(complained, "Should have handled failure to find using the given handler");
        }
Ejemplo n.º 17
0
        public void ShouldWaitForTabToBeSelected()
        {
            var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("History"));

            new Thread(o =>
            {
                Thread.Sleep(100);
                tab.Select();
            }).Start(null);

            Assert.True(tab.WaitFor(
                            (src, e) => tab.HasFocus(),
                            src => Assert.Fail()));
        }
Ejemplo n.º 18
0
        public void ShouldWaitForTextToBeChanged()
        {
            Window window = LaunchPetShopWindow();

            window.Find <Tab>(FindBy.WpfText("History")).Select();
            var box = window.Find <RichTextBox>("historyInput");

            new Thread(o =>
            {
                Thread.Sleep(100);
                box.Text = "Fred";
            }).Start(null);
            Assert.True(box.WaitFor(
                            (src, e) => box.Text.Equals("Fred"),
                            src => Assert.Fail()));
        }
Ejemplo n.º 19
0
        public void ShouldWaitForContentsOfBlockToChange()
        {
            var window = LaunchPetShopWindow();
            var tab    = window.Find <Tab>(FindBy.WpfText("History"));

            tab.Select();
            new Thread(() =>
            {
                var box  = window.Find <RichTextBox>("historyInput");
                box.Text = string.Empty;
            }).Start();

            var block = window.Find <TextBlock>("historyOutput");

            block.WaitFor((b, e) => ((TextBlock)b).Text.Equals(string.Empty), b => Assert.Fail("Should have had empty text"));
            Assert.AreEqual(string.Empty, block.Text);
        }
Ejemplo n.º 20
0
        public void AreSelected(params string[] accessoryNames)
        {
            var accessoriesTab = _universe.Window.Find <Tab>(FindBy.WpfText("Accessories"));

            accessoriesTab.Select();
            var scrollViewer =
                accessoriesTab.Find <ScrollViewer>(new PropertyCondition(AutomationElement.IsScrollPatternAvailableProperty, true));

            var table = accessoriesTab.Find <ListBox>("accessoriesOutput");

            foreach (var name in accessoryNames)
            {
                var nameForThisLoop = name;
                scrollViewer.ScrollDown(s => s.Contains(nameForThisLoop), s => {});
                scrollViewer.ScrollUp(s => s.Contains(FindBy.WpfText(nameForThisLoop)), (s2) => Assert.Fail("Should have scrolled to {0}" + nameForThisLoop));
            }
            table.Select(CollectionUtils.Convert(accessoryNames, name => "Accessory[" + name + "]").ToArray());
        }
Ejemplo n.º 21
0
        public void ShouldFindAnElementBasedOnAProperty()
        {
            var window = LaunchPetShopWindow();
            var basket = window.Find <Tab>(FindBy.WpfText("Basket"));

            AutomationElement comboBoxElement = window.Element.FindFirst(TreeScope.Descendants,
                                                                         new PropertyCondition(AutomationElement.ClassNameProperty,
                                                                                               typeof(ComboBox).Name));
            string comboBoxName = comboBoxElement.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty).ToString();

            var wrapperFactory = new Mock <IWrapAutomationElements>();
            var comboBox       = new ComboBox(comboBoxElement, "aComboBox");

            wrapperFactory.Setup(x => x.Wrap <ComboBox>(comboBoxElement, comboBoxName)).Returns(comboBox);

            var finder = new ConditionBasedFinder(wrapperFactory.Object, new Mock <IDescribeConditions>().Object);

            finder.Find <ComboBox>(basket, FindBy.ControlType(ControlType.ComboBox), Assert.Fail);
        }
Ejemplo n.º 22
0
 public void IsReset()
 {
     _universe.Window.Find <Tab>(FindBy.WpfText("Basket")).Select();
     _universe.Window.Find <Button>("resetButton").Click();
 }
Ejemplo n.º 23
0
        public void ShouldProvideItsTitle()
        {
            var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("History"));

            Assert.AreEqual("History", tab.Title);
        }