diff --git a/release_notes.md b/release_notes.md index 3bc2f4b6d..08fa98f8b 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,8 @@ ###In Development + - [#137](https://github.com/MehdiK/Humanizer/pull/137): + - Fixed grammar error in `nb-NO` resource file + - Added missing Norwegian resource strings (mainly `DateHumanize_*FromNow`) with tests + - Added tests for Norwegian `TimeSpan` resource strings [Commits](https://github.com/MehdiK/Humanizer/compare/v1.17.1...master) diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 444ac46d6..31fddff49 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -78,6 +78,7 @@ + diff --git a/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs index b8ac85b51..655de1b80 100644 --- a/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs +++ b/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs @@ -20,6 +20,26 @@ 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); + } + + [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 +50,37 @@ 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 +91,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 +115,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); + } + } } diff --git a/src/Humanizer.Tests/Localisation/nb-NO/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/nb-NO/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..302ba36d5 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/nb-NO/TimeSpanHumanizeTests.cs @@ -0,0 +1,65 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.nbNO +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + 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()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Properties/Resources.nb-NO.resx b/src/Humanizer/Properties/Resources.nb-NO.resx index c2a7b8c10..240a6ba25 100644 --- a/src/Humanizer/Properties/Resources.nb-NO.resx +++ b/src/Humanizer/Properties/Resources.nb-NO.resx @@ -118,13 +118,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - et sekund siden + ett sekund siden {0} sekunder siden - et minutt siden + ett minutt siden {0} minutter siden @@ -148,7 +148,7 @@ {0} måneder siden - et år siden + ett år siden {0} år siden @@ -175,13 +175,13 @@ en time - et millisekund + ett millisekund - et minutt + ett minutt - et sekund + ett sekund ingen tid @@ -192,4 +192,43 @@ en uke + + {0} dager fra nå + + + {0} timer fra nå + + + {0} minutter fra nå + + + {0} måneder fra nå + + + {0} sekunder fra nå + + + {0} år fra nå + + + + + + i morgen + + + en time fra nå + + + ett minutt fra nå + + + en måned fra nå + + + ett sekund fra nå + + + ett år fra nå + \ No newline at end of file