Exemplo n.º 1
0
        public void TestClickItemWhenHoveringProducesSpecificErrorReturnsSuccess()
        {
            var propData = new Mock <IPropertyData>(MockBehavior.Strict);

            propData.Setup(p => p.WaitForElementCondition(WaitConditions.NotMoving, null)).Returns(true);
            propData.Setup(p => p.WaitForElementCondition(WaitConditions.BecomesEnabled, null)).Returns(true);
            propData.Setup(p => p.ClickElement()).Throws(new ApplicationException("Element is not clickable at point"));

            var locator = new Mock <IElementLocator>(MockBehavior.Strict);

            locator.Setup(p => p.GetElement("myproperty")).Returns(propData.Object);

            var hoverOverElementAction = new HoverOverElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new ActionContext("myproperty");
            var result  = hoverOverElementAction.Execute(context);

            Assert.AreEqual(true, result.Success);

            locator.VerifyAll();
            propData.VerifyAll();
        }
Exemplo n.º 2
0
        public void TestClickItemWhenWaitIsEnabledReturnsSuccess()
        {
            var propData = new Mock <IPropertyData>(MockBehavior.Strict);

            propData.Setup(p => p.ClickElement());

            var locator = new Mock <IElementLocator>(MockBehavior.Strict);

            locator.Setup(p => p.GetElement("myproperty")).Returns(propData.Object);

            HoverOverElementAction.WaitForStillElementBeforeClicking = false;

            var hoverOverElementAction = new HoverOverElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new ActionContext("myproperty");
            var result  = hoverOverElementAction.Execute(context);

            Assert.AreEqual(true, result.Success);

            locator.VerifyAll();
            propData.VerifyAll();
        }
Exemplo n.º 3
0
        public void TestClickItemWhenSomeOtherErrorHappensReturnsFailure()
        {
            var propData = new Mock <IPropertyData>(MockBehavior.Strict);

            propData.Setup(p => p.WaitForElementCondition(WaitConditions.NotMoving, null)).Returns(true);
            propData.Setup(p => p.WaitForElementCondition(WaitConditions.BecomesEnabled, null)).Returns(true);
            propData.Setup(p => p.ClickElement()).Throws(new ApplicationException("Some Other Error"));

            var locator = new Mock <IElementLocator>(MockBehavior.Strict);

            locator.Setup(p => p.GetElement("myproperty")).Returns(propData.Object);

            var hoverOverElementAction = new HoverOverElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new ActionContext("myproperty");
            var result  = hoverOverElementAction.Execute(context);

            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("Some Other Error", result.Exception.Message);

            locator.VerifyAll();
            propData.VerifyAll();
        }
Exemplo n.º 4
0
        public void TestClickItemFieldDoesNotExist()
        {
            var locator = new Mock <IElementLocator>(MockBehavior.Strict);

            locator.Setup(p => p.GetElement("doesnotexist")).Throws(new ElementExecuteException("Cannot find item"));

            var hoverOverElementAction = new HoverOverElementAction
            {
                ElementLocator = locator.Object
            };

            var context = new ActionContext("doesnotexist");

            ExceptionHelper.SetupForException <ElementExecuteException>(
                () => hoverOverElementAction.Execute(context), e => locator.VerifyAll());
        }
Exemplo n.º 5
0
        public void TestGetActionName()
        {
            var hoverOverElementAction = new HoverOverElementAction();

            Assert.AreEqual("HoverOverElementAction", hoverOverElementAction.Name);
        }