public void ShouldAllowTheWaiterToWaitForEventsToHappen()
        {
            // Given an element and a waiter
            var waiter = new Mock<IWaitForEvents>();
            var element = new StubAutomationElementWrapper(AutomationElement.RootElement, "Desktop", waiter.Object);

            // When we wait for an event successfully
            waiter.Setup(w => w.WaitFor(
                                  It.IsAny<AutomationElementWrapper>(),
                                  It.IsAny<SomethingToWaitFor>(),
                                  It.IsAny<TimeSpan>(),
                                  It.IsAny<FailureToHappenHandler>(),
                                  It.IsAny<IEnumerable<AutomationEventWrapper>>())).Returns(true);
            var result = element.WaitFor((src, e) => true, new TimeSpan(0, 0, 1), (src) => Assert.Fail());

            // Then we should be successful
            Assert.IsTrue(result);

            // When the event fails
            waiter.Setup(w => w.WaitFor(
                                  It.IsAny<AutomationElementWrapper>(),
                                  It.IsAny<SomethingToWaitFor>(),
                                  It.IsAny<TimeSpan>(),
                                  It.IsAny<FailureToHappenHandler>(),
                                  It.IsAny<IEnumerable<AutomationEventWrapper>>())).Returns(false);
            result = element.WaitFor((src, e) => false, new TimeSpan(0, 0, 1), (src) => Assert.Fail());

            // Then we should know
            Assert.IsFalse(result);
        }
Ejemplo n.º 2
0
        public void ShouldAllowTheWaiterToWaitForEventsToHappen()
        {
            // Given an element and a waiter
            var waiter  = new Mock <IWaitForEvents>();
            var element = new StubAutomationElementWrapper(AutomationElement.RootElement, "Desktop", waiter.Object);

            // When we wait for an event successfully
            waiter.Setup(w => w.WaitFor(
                             It.IsAny <AutomationElementWrapper>(),
                             It.IsAny <SomethingToWaitFor>(),
                             It.IsAny <TimeSpan>(),
                             It.IsAny <FailureToHappenHandler>(),
                             It.IsAny <IEnumerable <AutomationEventWrapper> >())).Returns(true);
            var result = element.WaitFor((src, e) => true, new TimeSpan(0, 0, 1), (src) => Assert.Fail());

            // Then we should be successful
            Assert.IsTrue(result);

            // When the event fails
            waiter.Setup(w => w.WaitFor(
                             It.IsAny <AutomationElementWrapper>(),
                             It.IsAny <SomethingToWaitFor>(),
                             It.IsAny <TimeSpan>(),
                             It.IsAny <FailureToHappenHandler>(),
                             It.IsAny <IEnumerable <AutomationEventWrapper> >())).Returns(false);
            result = element.WaitFor((src, e) => false, new TimeSpan(0, 0, 1), (src) => Assert.Fail());

            // Then we should know
            Assert.IsFalse(result);
        }
 public void ShouldProvideTheNameWithWhichItWasConstructed()
 {
     var element = new StubAutomationElementWrapper(AutomationElement.RootElement, "nameOfElement");
     Assert.AreEqual("nameOfElement", element.Name);
 }
 public void ShouldProvideAccessToTheUnderlyingAutomationElement()
 {
     var element = new StubAutomationElementWrapper(AutomationElement.RootElement, "Desktop");
     Assert.AreEqual(AutomationElement.RootElement, element.Element);
 }
Ejemplo n.º 5
0
        public void ShouldProvideTheNameWithWhichItWasConstructed()
        {
            var element = new StubAutomationElementWrapper(AutomationElement.RootElement, "nameOfElement");

            Assert.AreEqual("nameOfElement", element.Name);
        }
Ejemplo n.º 6
0
        public void ShouldProvideAccessToTheUnderlyingAutomationElement()
        {
            var element = new StubAutomationElementWrapper(AutomationElement.RootElement, "Desktop");

            Assert.AreEqual(AutomationElement.RootElement, element.Element);
        }