private static GivenStep ParseBackgroundStep(LineReader reader) { if (!reader.IsGivenLine && !reader.IsAndLine && !reader.IsButLine) { throw new NotSupportedException( $"Unrecognised step type on line '{reader.CurrentLineTrimmed}'. Only Given, And or But steps can be used in a Background."); } var stepTitle = reader.CurrentLineTrimmed; reader.ReadNextLine(); var multiLineString = MultiLineStringParser.ParseMultiLineStringIfPresent(reader); var dataTable = DataTable.Empty; if (reader.IsTableLine) { dataTable = DataTableParser.ParseDataTable(reader); } return(new GivenStep( stepTitle, dataTable, multiLineString)); }
private static IStep ParseStep(LineReader reader, Func <DataTable, string, IStep> stepFactory) { reader.ReadNextLine(); var multiLineString = MultiLineStringParser.ParseMultiLineStringIfPresent(reader); var dataTable = DataTable.Empty; if (reader.IsTableLine) { dataTable = DataTableParser.ParseDataTable(reader); } return(stepFactory(dataTable, multiLineString)); }