Beispiel #1
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 #2
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" }
            });

            Assert.Throws <InvalidOperationException>(() =>
                                                      ExceptionHelper.SetupForException <InvalidOperationException>(
                                                          () => steps.ThenISeeListStep("myfield", "invalid", table),
                                                          ex =>
            {
                scenarioContext.VerifyAll();
                pipelineService.VerifyAll();
            }));
        }
Beispiel #3
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 #4
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 #5
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 #6
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();
                });
        }