public void Execute(Fixture fixture, Action next) { foreach (var @case in fixture.Cases) { using (var console = new RedirectedConsole()) { @case.Fixture = fixture; var stopwatch = new Stopwatch(); stopwatch.Start(); try { caseBehaviors.Execute(@case); } catch (Exception exception) { @case.Fail(exception); } stopwatch.Stop(); @case.Fixture = null; @case.Duration = stopwatch.Elapsed; @case.Output = console.Output; } Console.Write(@case.Output); } }
public void ShouldDoNothingWhenEmpty() { var context = new BreadCrumbs(); var chain = new BehaviorChain <BreadCrumbs>(); chain.Execute(context); context.Crumbs.ShouldBeEmpty(); context.Exceptions.ShouldBeEmpty(); }
void PerformClassLifecycle(Class testClass, IReadOnlyList <Case> casesForThisInstance) { var instance = testClassFactory(testClass.Type); var fixture = new Fixture(testClass, instance, casesForThisInstance); fixtureBehaviors.Execute(fixture); (instance as IDisposable)?.Dispose(); }
public void ShouldExecuteBehaviorsInOrder() { var context = new BreadCrumbs(); var chain = new BehaviorChain <BreadCrumbs>( new OuterBehavior(), new InnerBehavior() ); chain.Execute(context); context.Crumbs.ShouldEqual( "Entering OuterBehavior", "Entering InnerBehavior", "Leaving InnerBehavior", "Leaving OuterBehavior"); }
public void ShouldHandleUncaughtExceptionsAtEachStepInTheChainByLoggingThemToTheContextObject() { var context = new BreadCrumbs(); var chain = new BehaviorChain <BreadCrumbs>( new OuterBehavior(), new InnerBehavior(), new BuggyBehavior() ); chain.Execute(context); context.Crumbs.ShouldEqual( "Entering OuterBehavior", "Entering InnerBehavior", "Entering BuggyBehavior", "Leaving InnerBehavior", "Leaving OuterBehavior"); context.Exceptions.Single().Message.ShouldEqual("BuggyBehavior Threw!"); }