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

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

            pipelineService.Setup(
                p => p.PerformAction <ClearDataAction>(testPage.Object, It.Is <ClearDataAction.ClearDataContext>(c => c.PropertyName == "myfield")))
            .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);

            var table = new Table("Field");

            table.AddRow(new Dictionary <string, string>
            {
                { "Field", "My Field" }
            });

            steps.WhenIClearDataInFieldsStep(table);

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

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

            pipelineService.Setup(
                p => p.PerformAction <ClearDataAction>(testPage.Object, It.Is <ClearDataAction.ClearDataContext>(c => c.PropertyName == "myfield")))
            .Returns(ActionResult.Successful());
            pipelineService.Setup(
                p => p.PerformAction <ClearDataAction>(testPage.Object, It.Is <ClearDataAction.ClearDataContext>(c => c.PropertyName == "mysecondfield")))
            .Returns(ActionResult.Failure(new ElementExecuteException("Could Not Find Field: mysecondfield")));

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

            scenarioContext.Setup(s => s.GetCurrentPage()).Returns(testPage.Object);

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

            var table = new Table("Field");

            table.AddRow(new Dictionary <string, string>
            {
                { "Field", "My Second Field" }
            });

            table.AddRow(new Dictionary <string, string>
            {
                { "Field", "My Field" }
            });

            Assert.Throws <ElementExecuteException>(() =>
            {
                try
                {
                    steps.WhenIClearDataInFieldsStep(table);
                }
                catch (ElementExecuteException ex)
                {
                    StringAssert.Contains("Could Not Find Field: mysecondfield", ex.Message);

                    scenarioContext.VerifyAll();
                    pipelineService.VerifyAll();
                    throw;
                }
            });
        }
Exemple #3
0
        public void TestWhenIClearDataInFieldsStepNullTable()
        {
            var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict);
            var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict);

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

            ExceptionHelper.SetupForException <ElementExecuteException>(
                () => steps.WhenIClearDataInFieldsStep(null),
                e =>
            {
                StringAssert.Contains(e.Message, "A table must be specified for this step");

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            });
        }
Exemple #4
0
        public void TestWhenIClearDataInFieldsStepMissingFieldColumn()
        {
            var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict);
            var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict);

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

            var table = new Table("Notes");

            Assert.Throws <ElementExecuteException>(() =>
                                                    ExceptionHelper.SetupForException <ElementExecuteException>(
                                                        () => steps.WhenIClearDataInFieldsStep(table),
                                                        e =>
            {
                StringAssert.Contains("A table must be specified for this step", e.Message);

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            }));
        }
Exemple #5
0
        public void TestWhenIClearDataInFieldsStepMultipleEntriesWithFailure()
        {
            var testPage = new Mock<IPage>();

            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            pipelineService.Setup(
                p => p.PerformAction<ClearDataAction>(testPage.Object, It.Is<ClearDataAction.ClearDataContext>(c => c.PropertyName == "myfield")))
                            .Returns(ActionResult.Successful());
            pipelineService.Setup(
                p => p.PerformAction<ClearDataAction>(testPage.Object, It.Is<ClearDataAction.ClearDataContext>(c => c.PropertyName == "mysecondfield")))
                            .Returns(ActionResult.Failure(new ElementExecuteException("Could Not Find Field: mysecondfield")));

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

            var table = new Table("Field");
            table.AddRow(new Dictionary<string, string>
                             {
                                 { "Field", "My Second Field" }
                             });

            table.AddRow(new Dictionary<string, string>
                             {
                                 { "Field", "My Field" }
                             });

            try
            {
                steps.WhenIClearDataInFieldsStep(table);
            }
            catch (ElementExecuteException ex)
            {
                StringAssert.Contains(ex.Message, "Could Not Find Field: mysecondfield");

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
                throw;
            }
        }
Exemple #6
0
        public void TestWhenIClearDataInFieldsStep()
        {
            var testPage = new Mock<IPage>();

            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            pipelineService.Setup(
                p => p.PerformAction<ClearDataAction>(testPage.Object, It.Is<ClearDataAction.ClearDataContext>(c => c.PropertyName == "myfield")))
                            .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);

            var table = new Table("Field");
            table.AddRow(new Dictionary<string, string>
                             {
                                 { "Field", "My Field" }
                             });

            steps.WhenIClearDataInFieldsStep(table);

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Exemple #7
0
        public void TestWhenIClearDataInFieldsStepMissingFieldColumn()
        {
            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            var scenarioContext = new Mock<IScenarioContextHelper>(MockBehavior.Strict);

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

            var table = new Table("Notes");

            ExceptionHelper.SetupForException<ElementExecuteException>(
                () => steps.WhenIClearDataInFieldsStep(table),
                e =>
                {
                    StringAssert.Contains(e.Message, "A table must be specified for this step");

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