Example #1
0
        public void TestWhenIEnterDataInFieldStepWithFailure()
        {
            var testPage = new Mock <IPage>();

            var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict);

            pipelineService.Setup(
                p => p.PerformAction <EnterDataAction>(testPage.Object, It.Is <EnterDataAction.EnterDataContext>(c => c.PropertyName == "myfield" && c.Data == "myvalue")))
            .Returns(ActionResult.Failure(new ElementExecuteException("Could Not Find Field: myfield")));

            var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict);

            scenarioContext.Setup(s => s.GetValue <IPage>(PageStepBase.CurrentPageKey)).Returns(testPage.Object);

            var steps = new DataSteps(scenarioContext.Object, pipelineService.Object);

            try
            {
                steps.WhenIEnterDataInFieldStep("myvalue", "My Field");
            }
            catch (ElementExecuteException ex)
            {
                StringAssert.Contains(ex.Message, "Could Not Find Field: myfield");

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
                throw;
            }
        }
Example #2
0
        public void TestWhenIEnterDataInFieldStep()
        {
            var testPage = new Mock <IPage>();

            var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict);

            pipelineService.Setup(
                p => p.PerformAction <EnterDataAction>(testPage.Object, It.Is <EnterDataAction.EnterDataContext>(c => c.PropertyName == "myfield" && c.Data == "myvalue")))
            .Returns(ActionResult.Successful());

            var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict);

            scenarioContext.Setup(s => s.GetValue <IPage>(PageStepBase.CurrentPageKey)).Returns(testPage.Object);

            var steps = new DataSteps(scenarioContext.Object, pipelineService.Object);

            steps.WhenIEnterDataInFieldStep("myvalue", "My Field");

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }