-
Notifications
You must be signed in to change notification settings - Fork 965
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
Default collection formatter not throwing exception #394
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Threading; | ||
using Humanizer.Localisation; | ||
using Humanizer.Localisation.Formatters; | ||
using Xunit; | ||
|
@@ -20,5 +21,25 @@ public void TimeSpanHumanizeThrowsExceptionForTimeUnitsLargerThanWeek(TimeUnit t | |
{ | ||
Assert.Throws<ArgumentOutOfRangeException>(() => new DefaultFormatter(CultureInfo.InvariantCulture.Name).TimeSpanHumanize(timeUnit, unit)); | ||
} | ||
|
||
[Fact] | ||
public void Issue_392_A_collection_formatter_for_the_current_culture_has_not_been_implemented_yet() | ||
{ | ||
var originalCulture = Thread.CurrentThread.CurrentCulture; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use something like: using(new AmbientCulture("es")) {
// test
} |
||
var originalUiCulture = Thread.CurrentThread.CurrentUICulture; | ||
|
||
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("es"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to use different culture, because "es" culture is going to be implemented some day, and the test will break. |
||
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("es"); | ||
|
||
// start: code from issue report | ||
var a = new[] { DateTime.UtcNow, DateTime.UtcNow.AddDays(10) }; | ||
var b = a.Humanize(); // THROWS! | ||
// end: code from issue report | ||
|
||
Assert.Equal(a[0] + " & " + a[1], b); | ||
|
||
Thread.CurrentThread.CurrentCulture = originalCulture; | ||
Thread.CurrentThread.CurrentUICulture = originalUiCulture; | ||
} | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see where you're going with the method name; but it's inconsistent with the rest of the codebase. Please rename it to something like
HandlesNotImplementedCollectionFormattersGracefully
. You can provide an actual url to the issue on GitHub in a comment.