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());
		}
		public void TestClickItemSuccess()
		{
			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());

			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();
		}
        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();
        }
        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();
        }