Skip to content

Commit

Permalink
fix usage feature language from config
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparnagy committed Nov 11, 2009
1 parent 94a93bd commit 9b7b8d8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Parser/SpecFlowGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public CodeCompileUnit GenerateTestFileCode(string featureFileName, string conte
SpecFlowFeatureFile featureFile = GetFeatureFile(featureFileName);
string targetNamespace = GetTargetNamespace(featureFile);

SpecFlowLangParser parser = new SpecFlowLangParser();
SpecFlowLangParser parser = new SpecFlowLangParser(project.GeneratorConfiguration.FeatureLanguage);
Feature feature = parser.Parse(new StringReader(content), featureFile.GetFullPath(project));

IUnitTestGeneratorProvider generatorProvider = CreateInstance<IUnitTestGeneratorProvider>(project.GeneratorConfiguration.GeneratorUnitTestProviderType);
Expand Down
12 changes: 3 additions & 9 deletions Parser/SpecFlowLangParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System.Globalization;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Antlr.Runtime;
using Antlr.Runtime.Tree;
Expand All @@ -15,11 +13,7 @@ namespace TechTalk.SpecFlow.Parser
{
public class SpecFlowLangParser
{
private CultureInfo defaultLanguage;

public SpecFlowLangParser() : this(new CultureInfo("en-US"))
{
}
private readonly CultureInfo defaultLanguage;

public SpecFlowLangParser(CultureInfo defaultLanguage)
{
Expand Down Expand Up @@ -57,7 +51,7 @@ public Feature Parse(TextReader featureFileReader)
throw new SpecFlowParserException("Invalid Gherkin file!", lexer.LexerErrors.Concat(parser.ParserErrors).ToArray());
}

var walker = new Grammar.SpecFlowLangWalker(new CommonTreeNodeStream(featureTree));
var walker = new SpecFlowLangWalker(new CommonTreeNodeStream(featureTree));

Feature feature = walker.feature();

Expand All @@ -69,7 +63,7 @@ public Feature Parse(TextReader featureFileReader)
return feature;
}

static readonly Dictionary<CultureInfo, Type> lexters = new Dictionary<CultureInfo, Type>()
static readonly Dictionary<CultureInfo, Type> lexters = new Dictionary<CultureInfo, Type>
{
{new CultureInfo("en"), typeof(SpecFlowLangLexer_en)},
{new CultureInfo("de"), typeof(SpecFlowLangLexer_de)},
Expand Down
9 changes: 5 additions & 4 deletions Reporting/ParserHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using TechTalk.SpecFlow.Parser;
using TechTalk.SpecFlow.Parser.Configuration;
using TechTalk.SpecFlow.Parser.SyntaxElements;
Expand All @@ -13,15 +13,16 @@ static class ParserHelper
{
public static List<Feature> GetParsedFeatures(SpecFlowProject specFlowProject)
{
return GetParsedFeatures(specFlowProject.FeatureFiles.Select(ff => ff.GetFullPath(specFlowProject)));
return GetParsedFeatures(specFlowProject.FeatureFiles.Select(ff => ff.GetFullPath(specFlowProject)),
specFlowProject.GeneratorConfiguration.FeatureLanguage);
}

public static List<Feature> GetParsedFeatures(IEnumerable<string> featureFiles)
public static List<Feature> GetParsedFeatures(IEnumerable<string> featureFiles, CultureInfo featureLanguage)
{
List<Feature> parsedFeatures = new List<Feature>();
foreach (var featureFile in featureFiles)
{
SpecFlowLangParser parser = new SpecFlowLangParser();
SpecFlowLangParser parser = new SpecFlowLangParser(featureLanguage);
using (var reader = new StreamReader(featureFile))
{
Feature feature = parser.Parse(reader, featureFile);
Expand Down
3 changes: 2 additions & 1 deletion Tests/ParserTests/SuccessfulGenerationTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -128,7 +129,7 @@ public void CanGenerateMixedGWTFeature()
public void CanGenerateFromFile(string fileName)
{
Console.WriteLine(fileName);
SpecFlowLangParser parser = new SpecFlowLangParser();
SpecFlowLangParser parser = new SpecFlowLangParser(new CultureInfo("en"));
using (var reader = new StreamReader(fileName))
{
Feature feature = parser.Parse(reader);
Expand Down
3 changes: 2 additions & 1 deletion Tests/ParserTests/SuccessfulParsingTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -130,7 +131,7 @@ public void CanParseMixedGWTFeature()
public void CanParseFile(string fileName)
{
Console.WriteLine(fileName);
SpecFlowLangParser parser = new SpecFlowLangParser();
SpecFlowLangParser parser = new SpecFlowLangParser(new CultureInfo("en"));
using (var reader = new StreamReader(fileName))
{
Feature feature = parser.Parse(reader);
Expand Down
3 changes: 2 additions & 1 deletion Tests/RuntimeTests/ExecutionTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Microsoft.CSharp;
Expand Down Expand Up @@ -146,7 +147,7 @@ public void CanExecuteMixedGWTFeature()
public void CanGenerateFromFile(string fileName)
{
Console.WriteLine(fileName);
SpecFlowLangParser parser = new SpecFlowLangParser();
SpecFlowLangParser parser = new SpecFlowLangParser(new CultureInfo("en"));
using (var reader = new StreamReader(fileName))
{
Feature feature = parser.Parse(reader);
Expand Down

0 comments on commit 9b7b8d8

Please sign in to comment.