-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Binding methods are executed using the culture of the feature file.
- Loading branch information
1 parent
4f604dc
commit 851e6e0
Showing
11 changed files
with
168 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Threading; | ||
using TechTalk.SpecFlow.Tracing; | ||
|
||
namespace TechTalk.SpecFlow | ||
{ | ||
public class CultureInfoScope : IDisposable | ||
{ | ||
private readonly CultureInfo originalCultureInfo; | ||
|
||
public CultureInfoScope(CultureInfo cultureInfo) | ||
{ | ||
if (cultureInfo != null && !cultureInfo.Equals(Thread.CurrentThread.CurrentCulture)) | ||
{ | ||
if (cultureInfo.IsNeutralCulture) | ||
{ | ||
cultureInfo = LanguageHelper.GetSpecificCultureInfo(cultureInfo); | ||
} | ||
originalCultureInfo = Thread.CurrentThread.CurrentCulture; | ||
Thread.CurrentThread.CurrentCulture = cultureInfo; | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (originalCultureInfo != null) | ||
Thread.CurrentThread.CurrentCulture = originalCultureInfo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
Tests/RuntimeTests/StepExecutionTestsWithConversionsInNonEnglishCulture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Threading; | ||
using NUnit.Framework; | ||
using Rhino.Mocks; | ||
|
||
namespace TechTalk.SpecFlow.RuntimeTests | ||
{ | ||
[Binding] | ||
public class StepExecutionTestsBindingsForArgumentConvertInNonEnglishCulture | ||
{ | ||
[Given("argument (.*) should be able to convert to (.*)")] | ||
public virtual void InBindingConversion(string doubleParam, double expectedValue) | ||
{ | ||
double value = Convert.ToDouble(doubleParam); | ||
Assert.AreEqual(expectedValue, value); | ||
|
||
Assert.AreEqual("de-DE", Thread.CurrentThread.CurrentCulture.Name); | ||
} | ||
} | ||
|
||
|
||
[TestFixture] | ||
public class StepExecutionTestsWithConversionsInNonEnglishCulture : StepExecutionTestsBase | ||
{ | ||
protected override CultureInfo GetLanguage() | ||
{ | ||
return new CultureInfo("de-DE"); | ||
} | ||
|
||
[Test] | ||
public void SholdCallBindingWithSimpleConvertParam() | ||
{ | ||
StepExecutionTestsBindings bindingInstance; | ||
TestRunner testRunner = GetTestRunnerFor(out bindingInstance); | ||
|
||
bindingInstance.Expect(b => b.BindingWithSimpleConvertParam(1.23)); | ||
|
||
MockRepository.ReplayAll(); | ||
|
||
testRunner.Given("sample step with simple convert param: 1,23"); // German uses , as decimal separator | ||
|
||
Assert.AreEqual(TestStatus.OK, ObjectContainer.ScenarioContext.TestStatus); | ||
MockRepository.VerifyAll(); | ||
} | ||
|
||
[Test] | ||
public void ShouldExecuteBindingWithTheProperCulture() | ||
{ | ||
TestRunner testRunner = GetTestRunnerFor(typeof(StepExecutionTestsBindingsForArgumentConvertInNonEnglishCulture)); | ||
|
||
MockRepository.ReplayAll(); | ||
|
||
testRunner.Given("argument 1,23 should be able to convert to 1,23"); // German uses , as decimal separator | ||
|
||
Assert.AreEqual(TestStatus.OK, ObjectContainer.ScenarioContext.TestStatus); | ||
MockRepository.VerifyAll(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters