Esempio n. 1
0
        public IEnumerable <IEvent> iterable(SourceEvent sourceEvent)
        {
            List <IEvent> events = new List <IEvent> ();

            try {
                GherkinDocument gherkinDocument = parser.Parse(new StringReader(sourceEvent.data));

                if (printSource)
                {
                    events.Add(sourceEvent);
                }
                if (printAst)
                {
                    events.Add(new GherkinDocumentEvent(sourceEvent.uri, gherkinDocument));
                }
                if (printPickles)
                {
                    throw new NotSupportedException("Gherkin.NET doesn't have a pickle compiler yet");
                }
            } catch (CompositeParserException e) {
                foreach (ParserException error in e.Errors)
                {
                    addErrorAttachment(events, error, sourceEvent.uri);
                }
            } catch (ParserException e) {
                addErrorAttachment(events, e, sourceEvent.uri);
            }
            return(events);
        }
Esempio n. 2
0
        public IEnumerable <IEvent> iterable(SourceEvent sourceEvent)
        {
            List <IEvent> events = new List <IEvent> ();

            try {
                GherkinDocument gherkinDocument = parser.Parse(new StringReader(sourceEvent.data));

                if (printSource)
                {
                    events.Add(sourceEvent);
                }
                if (printAst)
                {
                    events.Add(new GherkinDocumentEvent(sourceEvent.uri, gherkinDocument));
                }
                if (printPickles)
                {
                    List <Pickle> pickles = compiler.Compile(gherkinDocument);
                    foreach (Pickle pickle in pickles)
                    {
                        events.Add(new PickleEvent(sourceEvent.uri, pickle));
                    }
                }
            } catch (CompositeParserException e) {
                foreach (ParserException error in e.Errors)
                {
                    addErrorAttachment(events, error, sourceEvent.uri);
                }
            } catch (ParserException e) {
                addErrorAttachment(events, e, sourceEvent.uri);
            }
            return(events);
        }