-
Notifications
You must be signed in to change notification settings - Fork 966
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
Fixed error in nb-NO resource file, added resource strings and added tests #137
Changes from 4 commits
6e6d2ba
ce931aa
1a79787
4d8b5db
edfa596
6c7cf67
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 |
---|---|---|
|
@@ -20,6 +20,28 @@ public void DaysAgo(int days, string expected) | |
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "i morgen")] | ||
[InlineData(10, "10 dager fra nå")] | ||
[InlineData(28, "28 dager fra nå")] | ||
[InlineData(32, "en måned fra nå")] | ||
public void DaysFromNow(int days, string expected) | ||
{ | ||
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); | ||
} | ||
|
||
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. Please remove redundant empty lines :) |
||
|
||
[Theory] | ||
[InlineData(1, "ett sekund fra nå")] | ||
[InlineData(10, "10 sekunder fra nå")] | ||
[InlineData(59, "59 sekunder fra nå")] | ||
[InlineData(60, "ett minutt fra nå")] | ||
public void SecondsFromNow(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); | ||
} | ||
|
||
|
||
[Theory] | ||
[InlineData(-10, "10 timer siden")] | ||
[InlineData(-3, "3 timer siden")] | ||
|
@@ -30,16 +52,38 @@ public void HoursAgo(int hours, string expected) | |
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); | ||
} | ||
|
||
|
||
[Theory] | ||
[InlineData(1, "en time fra nå")] | ||
[InlineData(10, "10 timer fra nå")] | ||
[InlineData(23, "23 timer fra nå")] | ||
[InlineData(24, "i morgen")] | ||
public void HoursFromNow(int hours, string expected) | ||
{ | ||
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "10 minutter siden")] | ||
[InlineData(-3, "3 minutter siden")] | ||
[InlineData(-2, "2 minutter siden")] | ||
[InlineData(-1, "et minutt siden")] | ||
[InlineData(-1, "ett minutt siden")] | ||
public void MinutesAgo(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "ett minutt fra nå")] | ||
[InlineData(10, "10 minutter fra nå")] | ||
[InlineData(44, "44 minutter fra nå")] | ||
[InlineData(45, "en time fra nå")] | ||
[InlineData(119, "en time fra nå")] | ||
[InlineData(120, "2 timer fra nå")] | ||
public void MinutesFromNow(int minutes, string expected) | ||
{ | ||
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); | ||
} | ||
[Theory] | ||
[InlineData(-10, "10 måneder siden")] | ||
[InlineData(-3, "3 måneder siden")] | ||
|
@@ -50,11 +94,21 @@ public void MonthsAgo(int months, string expected) | |
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "en måned fra nå")] | ||
[InlineData(10, "10 måneder fra nå")] | ||
[InlineData(11, "11 måneder fra nå")] | ||
[InlineData(12, "ett år fra nå")] | ||
public void MonthsFromNow(int months, string expected) | ||
{ | ||
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(-10, "10 sekunder siden")] | ||
[InlineData(-3, "3 sekunder siden")] | ||
[InlineData(-2, "2 sekunder siden")] | ||
[InlineData(-1, "et sekund siden")] | ||
[InlineData(-1, "ett sekund siden")] | ||
public void SecondsAgo(int seconds, string expected) | ||
{ | ||
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); | ||
|
@@ -64,10 +118,26 @@ public void SecondsAgo(int seconds, string expected) | |
[InlineData(-10, "10 år siden")] | ||
[InlineData(-3, "3 år siden")] | ||
[InlineData(-2, "2 år siden")] | ||
[InlineData(-1, "et år siden")] | ||
[InlineData(-1, "ett år siden")] | ||
public void YearsAgo(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "ett år fra nå")] | ||
[InlineData(2, "2 år fra nå")] | ||
public void YearsFromNow(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0, "nå")] | ||
public void Now(int years, string expected) | ||
{ | ||
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace Humanizer.Tests.Localisation.nbNO | ||
{ | ||
public class TimeSpanHumanizeTests : AmbientCulture | ||
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. Thanks for translating the TimeSpan resources and for the tests. TimeSpan was added much later to the lib and so it's missing translation for a lot of languages. |
||
{ | ||
public TimeSpanHumanizeTests() : base("nb-NO") { } | ||
|
||
[Theory] | ||
[InlineData(7, "en uke")] | ||
[InlineData(14, "2 uker")] | ||
public void Weeks(int days, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "en dag")] | ||
[InlineData(2, "2 dager")] | ||
public void Days(int days, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "en time")] | ||
[InlineData(2, "2 timer")] | ||
public void Hours(int hours, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "ett minutt")] | ||
[InlineData(2, "2 minutter")] | ||
public void Minutes(int minutes, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "ett sekund")] | ||
[InlineData(2, "2 sekunder")] | ||
public void Seconds(int seconds, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, "ett millisekund")] | ||
[InlineData(2, "2 millisekunder")] | ||
public void Milliseconds(int milliseconds, string expected) | ||
{ | ||
Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void NoTime() | ||
{ | ||
Assert.Equal("ingen tid", TimeSpan.Zero.Humanize()); | ||
} | ||
} | ||
} |
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.
Thanks for adding the tests in. I am also a fan of boundary tests like you've done with 32. Good work.