public void TestExecuteWhenElementShouldBeEnabledAndIsNotEnabledReturnsFailure()
        {
            var propData = new Mock <IPropertyData>(MockBehavior.Strict);

            propData.SetupGet(p => p.Name).Returns("MyProperty");
            propData.Setup(p => p.CheckElementExists()).Returns(false);

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

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

            var buttonClickAction = new ValidateElementExistsAction
            {
                ElementLocator = locator.Object
            };

            var context = new ValidationCheckContext("myproperty", true);
            var result  = buttonClickAction.Execute(context);

            Assert.AreEqual(false, result.Success);
            Assert.AreEqual("Element 'MyProperty' does not exist on the page and should exist.", result.Exception.Message);

            locator.VerifyAll();
            propData.VerifyAll();
        }
        public void TestExecuteFieldDoesNotExist()
        {
            var locator = new Mock <IElementLocator>(MockBehavior.Strict);

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

            var buttonClickAction = new ValidateElementExistsAction
            {
                ElementLocator = locator.Object
            };

            var context = new ValidationCheckContext("doesnotexist", true);

            ExceptionHelper.SetupForException <ElementExecuteException>(
                () => buttonClickAction.Execute(context), e => locator.VerifyAll());
        }
        public void TestExecuteWhenElementShouldBeEnabledAndIsReturnsSuccess()
        {
            var propData = new Mock <IPropertyData>(MockBehavior.Strict);

            propData.Setup(p => p.CheckElementExists()).Returns(true);

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

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

            var buttonClickAction = new ValidateElementExistsAction
            {
                ElementLocator = locator.Object
            };

            var context = new ValidationCheckContext("myproperty", true);
            var result  = buttonClickAction.Execute(context);

            Assert.AreEqual(true, result.Success);

            locator.VerifyAll();
            propData.VerifyAll();
        }