Exemplo n.º 1
0
        public void TestSetTokenFromFieldStepSetsCurrentValue()
        {
            var page = new Mock<IPage>();
            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            pipelineService.Setup(
                p => p.PerformAction<SetTokenFromValueAction>(
                    page.Object,
                    It.Is<SetTokenFromValueAction.TokenFieldContext>(c => c.TokenName == "MyToken" && c.PropertyName == "somefield")))
                    .Returns(ActionResult.Successful("The Field Value"));

            var scenarioContext = new Mock<IScenarioContextHelper>(MockBehavior.Strict);
            scenarioContext.Setup(s => s.GetValue<IPage>(PageStepBase.CurrentPageKey)).Returns(page.Object);

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

            steps.SetTokenFromFieldStep("MyToken", "SomeField");

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Exemplo n.º 2
0
        public void TestSetTokenFromFieldStepSetsCurrentValue()
        {
            var page            = new Mock <IPage>();
            var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict);

            pipelineService.Setup(
                p => p.PerformAction <SetTokenFromValueAction>(
                    page.Object,
                    It.Is <SetTokenFromValueAction.TokenFieldContext>(c => c.TokenName == "MyToken" && c.PropertyName == "somefield")))
            .Returns(ActionResult.Successful("The Field Value"));

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

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

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

            steps.SetTokenFromFieldStep("MyToken", "SomeField");

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Exemplo n.º 3
0
        public void TestValidateTokenStep()
        {
            var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict);
            pipelineService.Setup(
                p => p.PerformAction<ValidateTokenAction>(
                    null,
                    It.Is<ValidateTokenAction.ValidateTokenActionContext>(
                    c => c.ValidationTable.ValidationCount == 1 &&
                         c.ValidationTable.Validations.First().RawFieldName == "My Token" &&
                         c.ValidationTable.Validations.First().RawComparisonType == "Equals" &&
                         c.ValidationTable.Validations.First().RawComparisonValue == "test")))
                    .Returns(ActionResult.Successful());

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

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

            steps.ValidateTokenValueStep("My Token", "Equals ", " test");

            scenarioContext.VerifyAll();
            pipelineService.VerifyAll();
        }
Exemplo n.º 4
0
        public void TestValidateTokenStep()
        {
            var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict);

            pipelineService.Setup(
                p => p.PerformAction <ValidateTokenAction>(
                    null,
                    It.Is <ValidateTokenAction.ValidateTokenActionContext>(
                        c => c.ValidationTable.ValidationCount == 1 &&
                        c.ValidationTable.Validations.First().RawFieldName == "My Token" &&
                        c.ValidationTable.Validations.First().RawComparisonType == "Equals" &&
                        c.ValidationTable.Validations.First().RawComparisonValue == "test")))
            .Returns(ActionResult.Successful());

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

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

            steps.ValidateTokenValueStep("My Token", "Equals ", " test");

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