Beispiel #1
0
        public void TestWhenIEnterDataInFieldsStepNullTable()
        {
            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.WhenIEnterDataInFieldsStep(null),
                e =>
                {
                    StringAssert.Contains(e.Message, "A table must be specified for this step");

                    scenarioContext.VerifyAll();
                    pipelineService.VerifyAll();
                });
        }
Beispiel #2
0
        public void TestThenISeeStepEmptyTableRunsCorrectly()
        {
            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("Field", "Rule", "Value");

            ExceptionHelper.SetupForException <ElementExecuteException>(
                () => steps.ThenISeeStep(table),
                e =>
            {
                Assert.AreEqual(e.Message, "The validation table must contain at least one validation row.");

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            });
        }
Beispiel #3
0
        public void TestThenISeeStepMissingFieldColumn()
        {
            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("Value");

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

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            });
        }
Beispiel #4
0
        public void TestWhenIEnterDataInFieldsStepMissingValueColumn()
        {
            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("Field");

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

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            }));
        }
Beispiel #5
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();
        }
Beispiel #6
0
        public void TestThenISeeStepMultipleComparisons()
        {
            var testPage = new Mock <IPage>();

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

            pipelineService.Setup(p => p.PerformAction <ValidateItemAction>(testPage.Object,
                                                                            It.Is <ValidateItemAction.ValidateItemContext>(c =>
                                                                                                                           c.ValidationTable.Validations.Any(v => v.RawFieldName == "myfield" && v.RawComparisonValue == "myvalue" && v.RawComparisonType == "equals") &&
                                                                                                                           c.ValidationTable.Validations.Any(v => v.RawFieldName == "myotherfield" && v.RawComparisonValue == "somevalue" && v.RawComparisonType == "equals"))))
            .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", "Rule", "Value");

            table.AddRow(new Dictionary <string, string>
            {
                { "Field", "myfield" },
                { "Rule", "equals" },
                { "Value", "myvalue" }
            });

            table.AddRow(new Dictionary <string, string>
            {
                { "Field", "myotherfield" },
                { "Rule", "equals" },
                { "Value", "somevalue" }
            });

            steps.ThenISeeStep(table);

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Beispiel #7
0
        public void TestThenISeeAListRowCountStepWithAtLeastEvaluation()
        {
            var testPage = new Mock <IPage>();

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

            pipelineService.Setup(p => p.PerformAction <ValidateListRowCountAction>(testPage.Object,
                                                                                    It.Is <ValidateListRowCountAction.ValidateListRowCountContext>(
                                                                                        c => c.PropertyName == "myfield" && c.CompareType == NumericComparisonType.GreaterThanEquals && c.RowCount == 1)))
            .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.ThenISeeAListRowCountStep("myfield", "at least", 1);

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Beispiel #8
0
        public void TestThenISeeComboBoxContainsStepHasInvalidTable()
        {
            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("Item");

            table.AddRow(new Dictionary <string, string>
            {
                { "Item", "Something Cool" }
            });

            ExceptionHelper.SetupForException <ElementExecuteException>(
                () => steps.ThenISeeComboBoxContainsStep("myfield", "contains", table),
                ex =>
            {
                Assert.IsTrue(ex.Message.StartsWith("A table must be specified for this step"));

                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            });
        }
Beispiel #9
0
        public void TestThenISeeStepListInvalidRuleType()
        {
            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("Field", "Rule", "Value");

            table.AddRow(new Dictionary <string, string>
            {
                { "Field", "myfield" },
                { "Rule", "equals" },
                { "Value", "myvalue" }
            });

            ExceptionHelper.SetupForException <InvalidOperationException>(
                () => steps.ThenISeeListStep("myfield", "invalid", table),
                ex =>
            {
                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            });
        }
Beispiel #10
0
        public void TestThenISeeStepEmptyTableRunsCorrectly()
        {
            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("Field", "Rule", "Value");

            ExceptionHelper.SetupForException<ElementExecuteException>(
                () => steps.ThenISeeStep(table),
                e =>
                {
                    Assert.AreEqual(e.Message, "The validation table must contain at least one validation row.");

                    scenarioContext.VerifyAll();
                    pipelineService.VerifyAll();
                });
        }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ErrorCheckSteps" /> class.
 /// </summary>
 /// <param name="scenarioContext">The scenario context.</param>
 /// <param name="actionPipelineService">The action pipeline service.</param>
 public ErrorCheckSteps(IScenarioContextHelper scenarioContext, IActionPipelineService actionPipelineService)
 {
     this.dataSteps = new DataSteps(scenarioContext, actionPipelineService);
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ErrorCheckSteps" /> class.
 /// </summary>
 /// <param name="scenarioContext">The scenario context.</param>
 /// <param name="actionPipelineService">The action pipeline service.</param>
 public ErrorCheckSteps(IScenarioContextHelper scenarioContext, IActionPipelineService actionPipelineService)
 {
     this.dataSteps = new DataSteps(scenarioContext, actionPipelineService);
 }
Beispiel #13
0
        /// <summary>
        /// Runs the step list scenario.
        /// </summary>
        /// <param name="rule">The rule.</param>
        /// <param name="comparisonType">Type of the comparison.</param>
        private static void RunStepListScenario(string rule, ComparisonType comparisonType)
        {
            var testPage = new Mock<IPage>();

            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            pipelineService.Setup(p => p.PerformAction<ValidateListAction>(
                testPage.Object,
                It.Is<ValidateListAction.ValidateListContext>(c => c.PropertyName == "myfield" && c.CompareType == comparisonType)))
                .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", "Rule", "Value");
            table.AddRow(new Dictionary<string, string>
				             {
					             { "Field", "myfield" },
								 { "Rule", "equals" },
								 { "Value", "myvalue" }
				             });

            steps.ThenISeeListStep("myfield", rule, table);

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Beispiel #14
0
        public void TestThenISeeAListRowCountStepWithAtLeastEvaluation()
        {
            var testPage = new Mock<IPage>();

            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            pipelineService.Setup(p => p.PerformAction<ValidateListRowCountAction>(testPage.Object,
                 It.Is<ValidateListRowCountAction.ValidateListRowCountContext>(
                        c => c.PropertyName == "myfield" && c.CompareType == NumericComparisonType.GreaterThanEquals && c.RowCount == 1)))
                            .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.ThenISeeAListRowCountStep("myfield", "at least", 1);

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Beispiel #15
0
        public void TestThenISeeStepListNoRows()
        {
            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("Field", "Rule", "Value");

            steps.ThenISeeListStep("myfield", "contains", table);

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Beispiel #16
0
        public void TestThenISeeStepListInvalidRuleType()
        {
            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("Field", "Rule", "Value");
            table.AddRow(new Dictionary<string, string>
				             {
					             { "Field", "myfield" },
								 { "Rule", "equals" },
								 { "Value", "myvalue" }
				             });

            ExceptionHelper.SetupForException<InvalidOperationException>(
                () => steps.ThenISeeListStep("myfield", "invalid", table),
                ex =>
                {
                    scenarioContext.VerifyAll();
                    pipelineService.VerifyAll();
                });
        }
Beispiel #17
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();
        }
Beispiel #18
0
        public void TestThenISeeStepMissingRuleColumn()
        {
            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("Field", "Value");

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

                    scenarioContext.VerifyAll();
                    pipelineService.VerifyAll();
                });
        }
Beispiel #19
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;
            }
        }
Beispiel #20
0
        public void TestThenISeeStepMultipleComparisons()
        {
            var testPage = new Mock<IPage>();
            
            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            pipelineService.Setup(p => p.PerformAction<ValidateItemAction>(testPage.Object,
                It.Is<ValidateItemAction.ValidateItemContext>(c =>
                    c.ValidationTable.Validations.Any(v => v.RawFieldName == "myfield" && v.RawComparisonValue == "myvalue" && v.RawComparisonType == "equals") &&
                    c.ValidationTable.Validations.Any(v => v.RawFieldName == "myotherfield" && v.RawComparisonValue == "somevalue" && v.RawComparisonType == "equals"))))
                           .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", "Rule", "Value");
            table.AddRow(new Dictionary<string, string>
				             {
					             { "Field", "myfield" },
								 { "Rule", "equals" },
								 { "Value", "myvalue" }
				             });

            table.AddRow(new Dictionary<string, string>
				             {
					             { "Field", "myotherfield" },
								 { "Rule", "equals" },
								 { "Value", "somevalue" }
				             });

            steps.ThenISeeStep(table);

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

        }
 public void SeleInitialize()
 {
     dataSteps = new DataSteps();
 }