Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test data assumes specific culture #3

Open
JesHansen opened this issue Jun 4, 2021 · 0 comments
Open

Test data assumes specific culture #3

JesHansen opened this issue Jun 4, 2021 · 0 comments

Comments

@JesHansen
Copy link

The test data assumes a culture that can parse DateTimes in the format '1/19/7051'. This is not universally the case. If you are located somewhere that uses another format for dates, you will get an exception when running the test:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.FormatException: String '4/20/2847' was not recognized as a valid DateTime.
   at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   at System.Convert.ToDateTime(String value)
   at FileIO.WithAsyncStreams.<>c.<ProcessStreamAsync>b__1_1(String[] employeeLine) in C:\src\CSharpPerformanceBoosters\src\FileIO\WithAsyncStreams.cs:line 38
   at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
   at System.Linq.Enumerable.SelectListIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at FileIO.WithAsyncStreams.ProcessStreamAsync(String filePath) in C:\src\CSharpPerformanceBoosters\src\FileIO\WithAsyncStreams.cs:line 37
   at FileIO.Benchmarks.FileIOTest.AsyncStream() in C:\src\CSharpPerformanceBoosters\tests\FileIO.Benchmarks\FileIOTest.cs:line 48
   at BenchmarkDotNet.Autogenerated.Runnable_1.<.ctor>b__3_3() in C:\src\CSharpPerformanceBoosters\tests\FileIO.Benchmarks\bin\Release\net5.0\7ea90458-dc45-4102-9baf-2b1c22ea2ddc\7ea90458-dc45-4102-9baf-2b1c22ea2ddc.notcs:line 922
...
JesHansen added a commit to JesHansen/CSharpPerformanceBoosters that referenced this issue Jun 4, 2021
By specifying the invariant culture the tests are able to parse the
DateTimes correctly and run to completion, irregardless of how the
local systems Culture is configured.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant