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

Make tests works on systems with non english datetime format #258

Closed
wants to merge 1 commit into from

Conversation

MrJingle
Copy link
Contributor

If you set the system Date and Time format to Italian( or any other culture with a different date format than MM/dd/yyyy) the type initializer for NorthWindData will throw an exception on:

[...]
HireDate = ParseDate("8/14/1992 12:00:00 AM"), // the default it-IT date time format is dd/MM/yyyy
[..]
Exception details:

Test Name:  Any_simple
Test FullName:  Microsoft.Data.Entity.InMemory.FunctionalTests.NorthwindQueryTest.Any_simple
Test Source:    d:\MrJingle\Dev\Git\Forks\EntityFramework7\test\Shared\NorthwindQueryTestBase.cs : line 54
Test Outcome:   Failed
Test Duration:  0:00:00,001

Result Message: 
System.AggregateException : One or more errors occurred.
---- System.TypeInitializationException : The type initializer for 'Northwind.NorthwindData' threw an exception.
-------- System.FormatException : String was not recognized as a valid DateTime.
---- The following constructor arguments did not have matching fixture data: NorthwindQueryFixture fixture
Result StackTrace:  
----- Inner Stack Trace #1 (System.TypeInitializationException) -----
   at Microsoft.Data.Entity.InMemory.FunctionalTests.NorthwindQueryFixture..ctor() in d:\MrJingle\Dev\Git\Forks\EntityFramework7\test\Microsoft.Data.Entity.InMemory.FunctionalTests\NorthwindQueryTest.cs:line 39
----- Inner Stack Trace -----
   at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   at System.DateTime.Parse(String s)
   at Northwind.NorthwindData.ParseDate(String date) in d:\MrJingle\Dev\Git\Forks\EntityFramework7\test\Shared\Northwind.cs:line 303
   at Northwind.NorthwindData..cctor() in d:\MrJingle\Dev\Git\Forks\EntityFramework7\test\Shared\ **Northwind.cs:line 1590**
----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----

The fix is simply to change any occurrence of

   DateTime.Parse("date string")

with

   DateTime.Parse("date string", new CultureInfo("en-US"))

… Shared\Nothwind.cs works on machines with a culture different than 'en-US'.
@Eilon
Copy link
Member

Eilon commented May 25, 2014

Hi @MrJingle great find! Unfortunately we can't accept contributions just yet, but we're working on it, so once we allow that, we can work with you on this PR. Thanks!

@rowanmiller
Copy link
Contributor

Hi @MrJingle - thanks for your patience, if you can submit a Contributor License Agreement we will be able to process your pull request https://cla.msopentech.com/.

@MrJingle
Copy link
Contributor Author

MrJingle commented Jun 7, 2014

Ok,
i've sent the CLA.

@rowanmiller
Copy link
Contributor

@MrJingle - Thanks, just wanted to confirm that we received your CLA. Our legal team is processing it now.

@rowanmiller
Copy link
Contributor

@MrJingle - You should have received an email from our legal team to clarify a couple of things. You can ignore the question about your GitHub id, but if you could respond to the other question that would be great.

@MrJingle
Copy link
Contributor Author

Sorry,
I've checked, and i am no seeing any mail.
What sender should i look for?

Bye.

@rowanmiller
Copy link
Contributor

@MrJingle - I just emailed you using the email address you listed on the CLA. If you can just respond to that we can sort it out over email.

@rowanmiller
Copy link
Contributor

CLA questions are all sorted out now, this one is good to go.

@ajcvickers
Copy link
Contributor

This is now checked in. Thanks for the contribution!

@ajcvickers ajcvickers closed this Jun 26, 2014
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

Successfully merging this pull request may close these issues.

4 participants