public void YieldTheMostRecentWhenStepWhenGoToMostRecentWhenStepIsCalledDuringIteration() { var mostRecentWhenStep = new WhenStep("When something else", null, null); var steps = new List <IStep> { new GivenStep("Given something", null, null), new WhenStep("When something", null, null), mostRecentWhenStep, new ThenStep("Then something", null, null) }; var stepsIterator = new StepsIterator(steps); var readyToAssert = false; foreach (var step in stepsIterator.Iterate()) { if (readyToAssert) { Assert.AreEqual(mostRecentWhenStep, step); break; } if (step is ThenStep) { stepsIterator.GoToMostRecentWhenStep(); readyToAssert = true; } } }
private async Task <TestResultMessage[]> PerformEventuallyConsistentStepsTest(MethodInfo method) { var scenarioStep = new WhenStep("When an exception is thrown", DataTable.Empty, null); var testFeature = new Feature( "Feature", null, Background.Empty, new[] { new Scenario( "Scenario", new[] { scenarioStep }, 1, Enumerable.Empty <Tag>()) }, Enumerable.Empty <ScenarioOutline>(), Enumerable.Empty <Rule>(), Enumerable.Empty <Tag>()); var testData = new DiscoveredTestData(testAssembly, testFeature, null, testFeature.Scenarios.First()); var binding = new StepBinding(scenarioStep, method, Array.Empty <object>()); mockStepBinder .Setup(m => m.GetBindingFor(scenarioStep, testAssembly)) .Returns(binding); var testResult = await stepsExecutor.Execute(testCase, testData, testRunContext, mockLogger.Object); return(testResult .Messages .Where( message => message.Category == TestResultMessage.StandardOutCategory) .ToArray()); }
public async Task NotWrapExceptionsInATargetInvocationExceptionWhenInvokedMethodThrowsAnException() { var step = new WhenStep("an exception is thrown", null, null); var method = typeof(StepBindingStaticSamples).GetMethod("WhenAnExceptionIsThrown"); var binding = new StepBinding(step, method, Array.Empty <object>()); var exception = await Assert.ThrowsExceptionAsync <InvalidOperationException>( () => binding.Execute( mockServiceProvider.Object, new Collection <TestResultMessage>())); Assert.AreEqual("Hello", exception.Message); }
private async Task <TestResultMessage[]> PerformEventuallyConsistentScenarioTest(MethodInfo givenMethod, MethodInfo whenMethod, MethodInfo thenMethod) { var givenStep = new GivenStep("Given", DataTable.Empty, null); var whenStep = new WhenStep("When", DataTable.Empty, null); var thenStep = new ThenStep("Then", DataTable.Empty, null); var testFeature = new Feature( "Feature", null, Background.Empty, new[] { new Scenario( "Scenario", new IStep[] { givenStep, whenStep, thenStep }, 1, new List <Tag> { new Tag("eventuallyConsistent(retryInterval=00:00:01;within=00:00:05)") }) }, Enumerable.Empty <ScenarioOutline>(), Enumerable.Empty <Rule>(), Enumerable.Empty <Tag>()); var testData = new DiscoveredTestData(testAssembly, testFeature, null, testFeature.Scenarios.First()); var givenStepBinding = new StepBinding(givenStep, givenMethod, Array.Empty <object>()); var whenStepBinding = new StepBinding(whenStep, whenMethod, Array.Empty <object>()); var thenStepBinding = new StepBinding(thenStep, thenMethod, Array.Empty <object>()); mockStepBinder .Setup(m => m.GetBindingFor(givenStep, testAssembly)) .Returns(givenStepBinding); mockStepBinder .Setup(m => m.GetBindingFor(whenStep, testAssembly)) .Returns(whenStepBinding); mockStepBinder .Setup(m => m.GetBindingFor(thenStep, testAssembly)) .Returns(thenStepBinding); var testResult = await stepsExecutor.Execute(testCase, testData, testRunContext, mockLogger.Object); return(testResult .Messages .Where( message => message.Category == TestResultMessage.StandardOutCategory) .ToArray()); }
protected static void I_have_a_when_condition() { when = new WhenStep(new Scenario(), dummy_step, StepPrefix.When); }
private IFixtureStepRunner RunnerOf(WhenStep step) => new WhenStepRunner(step);