public void TestThenISeeStepEqualsComparison() { 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.All(v => v.RawFieldName == "myfield" && v.RawComparisonValue == "myvalue" && 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" } }); steps.ThenISeeStep(table); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }
public void TestThenISeeStepNullTable() { 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.ThenISeeStep(null), e => { StringAssert.Contains(e.Message, "A table must be specified for this step"); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }); }
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(); }); }
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"); Assert.Throws <ElementExecuteException>(() => ExceptionHelper.SetupForException <ElementExecuteException>( () => steps.ThenISeeStep(table), e => { StringAssert.Contains("A table must be specified for this step", e.Message); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); })); }
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 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(); }); }
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(); }); }