public void TestGoToListItemWithCriteriaStep() { var page = new Mock <IPage>(); var listItem = new Mock <IPage>(); var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict); pipelineService.Setup(p => p.PerformAction <GetListItemByCriteriaAction>( page.Object, It.Is <GetListItemByCriteriaAction.ListItemByCriteriaContext>( c => c.PropertyName == "myproperty" && c.ValidationTable.ValidationCount == 1))) .Returns(ActionResult.Successful(listItem.Object)); var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue <IPage>(PageStepBase.CurrentPageKey)).Returns(page.Object); scenarioContext.Setup(s => s.SetValue(listItem.Object, PageStepBase.CurrentPageKey)); var table = new Table("Field", "Rule", "Value"); table.AddRow("item1", "equals", "foo"); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); steps.GoToListItemWithCriteriaStep("my property", table); listItem.VerifyAll(); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }
public void TestGivenEnsureOnListItemStep() { var page = new Mock <IPage>(); var listItem = new Mock <IPage>(); var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict); pipelineService.Setup(p => p.PerformAction <GetListItemByIndexAction>( page.Object, It.Is <GetListItemByIndexAction.ListItemByIndexContext>(c => c.PropertyName == "myproperty" && c.ItemNumber == 2))) .Returns(ActionResult.Successful(listItem.Object)); var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue <IPage>(PageStepBase.CurrentPageKey)).Returns(page.Object); scenarioContext.Setup(s => s.SetValue(listItem.Object, PageStepBase.CurrentPageKey)); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); steps.GivenEnsureOnListItemStep("my property", 2); listItem.VerifyAll(); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }
public SelectionStep GotoNextSelectionStep(string comment = "") { SelectionStep nextStep; if (CurrentSelectionStep == null) { SelectionSteps = new List <SelectionStep>(); nextStep = new CvScreening(); } else { if (IsSelectionStepEndOfSelectionProcess()) { return(null); } else { nextStep = CurrentSelectionStep.GoToNextState(); } } if (!string.IsNullOrWhiteSpace(comment)) { nextStep.Comment = comment; } CurrentSelectionStep = nextStep; SelectionSteps.Add(nextStep); return(nextStep); }
public void TestWhenIChooseALinkStepContextNotSet() { var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict); var scenarioContext = new Mock<IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue<IPage>(PageStepBase.CurrentPageKey)).Returns((IPage)null); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); ExceptionHelper.SetupForException<PageNavigationException>( () => steps.WhenIChooseALinkStep("my link"), e => { scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }); }
public void TestWhenIChooseALinkStepContextNotSet() { var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict); var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue <IPage>(PageStepBase.CurrentPageKey)).Returns((IPage)null); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); ExceptionHelper.SetupForException <PageNavigationException>( () => steps.WhenIChooseALinkStep("my link"), e => { scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }); }
public void TestWhenIHoverOverAnElementStep() { var testPage = new Mock<IPage>(); var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict); pipelineService.Setup(p => p.PerformAction<HoverOverElementAction>(testPage.Object, It.Is<ActionContext>(c => c.PropertyName == "mylink"))) .Returns(ActionResult.Successful()); var pageMapper = new Mock<IPageMapper>(MockBehavior.Strict); var scenarioContext = new Mock<IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue<IPage>(PageStepBase.CurrentPageKey)).Returns(testPage.Object); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); steps.WhenIHoverOverAnElementStep("my link"); pageMapper.VerifyAll(); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }
public void TestWhenIHoverOverAnElementStep() { var testPage = new Mock <IPage>(); var pipelineService = new Mock <IActionPipelineService>(MockBehavior.Strict); pipelineService.Setup(p => p.PerformAction <HoverOverElementAction>(testPage.Object, It.Is <ActionContext>(c => c.PropertyName == "mylink"))) .Returns(ActionResult.Successful()); var pageMapper = new Mock <IPageMapper>(MockBehavior.Strict); var scenarioContext = new Mock <IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue <IPage>(PageStepBase.CurrentPageKey)).Returns(testPage.Object); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); steps.WhenIHoverOverAnElementStep("my link"); pageMapper.VerifyAll(); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }
public void TestGoToListItemWithCriteriaStep() { var page = new Mock<IPage>(); var listItem = new Mock<IPage>(); var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict); pipelineService.Setup(p => p.PerformAction<GetListItemByCriteriaAction>( page.Object, It.Is<GetListItemByCriteriaAction.ListItemByCriteriaContext>( c => c.PropertyName == "myproperty" && c.ValidationTable.ValidationCount == 1))) .Returns(ActionResult.Successful(listItem.Object)); var scenarioContext = new Mock<IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue<IPage>(PageStepBase.CurrentPageKey)).Returns(page.Object); scenarioContext.Setup(s => s.SetValue(listItem.Object, PageStepBase.CurrentPageKey)); var table = new Table("Field", "Rule", "Value"); table.AddRow("item1", "equals", "foo"); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); steps.GoToListItemWithCriteriaStep("my property", table); listItem.VerifyAll(); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }
public void TestGivenEnsureOnListItemStep() { var page = new Mock<IPage>(); var listItem = new Mock<IPage>(); var pipelineService = new Mock<IActionPipelineService>(MockBehavior.Strict); pipelineService.Setup(p => p.PerformAction<GetListItemByIndexAction>( page.Object, It.Is<GetListItemByIndexAction.ListItemByIndexContext>(c => c.PropertyName == "myproperty" && c.ItemNumber == 2))) .Returns(ActionResult.Successful(listItem.Object)); var scenarioContext = new Mock<IScenarioContextHelper>(MockBehavior.Strict); scenarioContext.Setup(s => s.GetValue<IPage>(PageStepBase.CurrentPageKey)).Returns(page.Object); scenarioContext.Setup(s => s.SetValue(listItem.Object, PageStepBase.CurrentPageKey)); var steps = new SelectionSteps(pipelineService.Object, scenarioContext.Object); steps.GivenEnsureOnListItemStep("my property", 2); listItem.VerifyAll(); scenarioContext.VerifyAll(); pipelineService.VerifyAll(); }