public LineStatus ExecuteLine(Scenario scenario, ScenarioContext scenarioContext, string line) { DebugTrace.Trace("ScenarioLineExecter.ExecuteLine", line); InvocationChain chain = GetMatchingChain(scenarioContext, line); if (chain == null) { var suggestion = _implementationHelper.Suggest(line); _eventBus.Raise(new LinePending { Scenario = scenario, Line = line, Suggestion = suggestion }); return(LineStatus.Pending); } if (!ExecuteChain(scenario, scenarioContext, chain, line)) { return(LineStatus.Failed); } _eventBus.Raise(new LinePassed { Scenario = scenario, Line = line }); return(LineStatus.Passed); }
public void SetupContext() { FakeResolver = MockRepository.GenerateMock <IAmbiguousMatchResolver>(); var factory = new InterpreterForTypeFactory(new AssemblyRegistry()); ChainReturnedFromResolver = new InvocationChain(); FakeResolver.Stub(x => x.ResolveMatch("", null)).IgnoreArguments().Return(ChainReturnedFromResolver); ScenarioInterpreter interpreter = new ScenarioInterpreter(factory, FakeResolver, new DefaultLanguageService()); Result = interpreter.GetChain( new ScenarioContext(new StoryContext(new FakeSessionContext()), new Type[] { typeof(AmbiguousTestClass) }, new Dictionary <Type, object>()), "Foo bar baz"); }
public void SetupContext() { FakeResolver = MockRepository.GenerateMock<IAmbiguousMatchResolver>(); var factory = new InterpreterForTypeFactory(new AssemblyRegistry()); ChainReturnedFromResolver = new InvocationChain(); FakeResolver.Stub(x => x.ResolveMatch("", null)).IgnoreArguments().Return(ChainReturnedFromResolver); ScenarioInterpreter interpreter = new ScenarioInterpreter(factory, FakeResolver, new DefaultLanguageService()); Result = interpreter.GetChain( new ScenarioContext(new StoryContext(new FakeSessionContext()), new Type[] {typeof (AmbiguousTestClass)}, new Dictionary<Type, object>()), "Foo bar baz"); }
private bool ExecuteChain(Scenario scenario, ScenarioContext storyContext, InvocationChain chain, string line) { string successPart = ""; _lastResult = null; foreach (var invocation in chain.Invocations) { try { InvokeContextMember(storyContext, invocation); successPart += invocation.MatchedText + " "; } catch (TargetInvocationException ex) { if (ex.InnerException is ScenarioPendingException) { _eventBus.Raise(new LinePending { Scenario = scenario, Line = line }); } else { _eventBus.Raise(new LineFailed { Scenario = scenario, Line = line, SuccessPart = successPart.Trim(), FailedPart = invocation.MatchedText, ExceptionInfo = GetExceptionMessage(ex) }); } return(false); } } return(true); }