public void Steps_should_get_access_to_DI_container_via_GetDependencyResolver() { var resolvers = new List <IDependencyResolver>(); void Step1() { resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver()); } void Step3() { resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver()); } void Step4() { resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver()); } TestCompositeStep Step2() { resolvers.Add(StepExecution.Current.GetScenarioDependencyResolver()); return(TestCompositeStep.Create(Step3, Step4)); } GetFeatureRunner().GetBddRunner(this).Test().TestScenario(TestStep.CreateSync(Step1), TestStep.CreateComposite(Step2)); Assert.That(resolvers.Count, Is.EqualTo(4)); Assert.That(resolvers.Any(x => x == null), Is.False); Assert.That(resolvers.Distinct().Count(), Is.EqualTo(1)); }
public void RunSynchronous_should_propagate_step_exception() { Assert.Throws <NotImplementedException>(() => _runner .Integrate() .NewScenario() .WithCapturedScenarioDetails() .WithSteps(new[] { TestStep.CreateSync(Test_throwing_exception) }) .RunSynchronously()); }
public void It_should_instantiate_new_scenario_progress_notifier_for_each_scenario() { var notifiers = new List <CapturingProgressNotifier>(); Func <object, IScenarioProgressNotifier> captureNotifierCreation = fixture => { var notifier = new CapturingProgressNotifier(); notifiers.Add(notifier); return(notifier); }; var runner = new TestableFeatureRunnerRepository(NoProgressNotifier.Default, captureNotifierCreation).GetRunnerFor(GetType()).GetBddRunner(this); runner.Test().TestNamedScenario("scenario1", TestStep.CreateSync(Given_step_one)); runner.Test().TestNamedScenario("scenario2", TestStep.CreateSync(Given_step_one)); runner.Test().TestNamedScenario("scenario3", TestStep.CreateSync(Given_step_one)); Assert.That(notifiers.Count, Is.EqualTo(3)); Assert.That(notifiers[0].Notifications.Count(n => n.StartsWith("Scenario Start: scenario1")), Is.EqualTo(1), "scenario1"); Assert.That(notifiers[1].Notifications.Count(n => n.StartsWith("Scenario Start: scenario2")), Is.EqualTo(1), "scenario2"); Assert.That(notifiers[2].Notifications.Count(n => n.StartsWith("Scenario Start: scenario3")), Is.EqualTo(1), "scenario3"); }
private TestCompositeStep Given_composite() { return(new TestCompositeStep( new ExecutionContextDescriptor(r => r.Resolve <MyStepScope>(), null), TestStep.CreateSync(Given_step_one))); }