diff --git a/release_notes.md b/release_notes.md
index da96eac3f..2e47c6561 100644
--- a/release_notes.md
+++ b/release_notes.md
@@ -1,4 +1,6 @@
###In Development
+ - [#124](https://github.com/MehdiK/Humanizer/pull/124): Added Slovak localization (strings, formatter, tests)
+ - [#130](https://github.com/MehdiK/Humanizer/pull/130): Added Czech localization (strings, formatter, tests)
[Commits](https://github.com/MehdiK/Humanizer/compare/v1.16.4...master)
diff --git a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt
index 47b0e9e8d..482b10d6d 100644
--- a/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt
+++ b/src/Humanizer.Tests/ApiApprover/PublicApiApprovalTest.approve_public_api.approved.txt
@@ -149,7 +149,7 @@ public enum LetterCasing
public class DefaultFormatter
{
public DefaultFormatter() { }
- public string DateHumanize(Humanizer.Localisation.TimeUnit timeUnit, Humanizer.Localisation.TimeUnitTense timeUnitTense, int unit) { }
+ public string DateHumanize(Humanizer.Localisation.TimeUnit timeUnit, Humanizer.Localisation.Tense timeUnitTense, int unit) { }
public string DateHumanize_Now() { }
public string TimeSpanHumanize(Humanizer.Localisation.TimeUnit timeUnit, int unit) { }
public string TimeSpanHumanize_Zero() { }
@@ -157,7 +157,7 @@ public class DefaultFormatter
public interface IFormatter
{
- string DateHumanize(Humanizer.Localisation.TimeUnit timeUnit, Humanizer.Localisation.TimeUnitTense timeUnitTense, int unit);
+ string DateHumanize(Humanizer.Localisation.TimeUnit timeUnit, Humanizer.Localisation.Tense timeUnitTense, int unit);
string DateHumanize_Now();
string TimeSpanHumanize(Humanizer.Localisation.TimeUnit timeUnit, int unit);
string TimeSpanHumanize_Zero();
@@ -173,6 +173,13 @@ public class Resources
public string GetResource(string resourceKey) { }
}
+public enum Tense
+{
+ Future,
+ Past,
+ value__,
+}
+
public enum TimeUnit
{
Day,
@@ -186,13 +193,6 @@ public enum TimeUnit
Year,
}
-public enum TimeUnitTense
-{
- Future,
- Past,
- value__,
-}
-
public class NoMatchFoundException
{
public NoMatchFoundException() { }
diff --git a/src/Humanizer.Tests/DateHumanize.cs b/src/Humanizer.Tests/DateHumanize.cs
new file mode 100644
index 000000000..871b561c5
--- /dev/null
+++ b/src/Humanizer.Tests/DateHumanize.cs
@@ -0,0 +1,62 @@
+using System;
+using Humanizer.Localisation;
+using Xunit;
+
+namespace Humanizer.Tests
+{
+ public class DateHumanize
+ {
+ static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow)
+ {
+ var utcNow = DateTime.UtcNow;
+ var localNow = DateTime.Now;
+
+ // feels like the only way to avoid breaking tests because CPU ticks over is to inject the base date
+ Assert.Equal(expectedString, utcNow.Add(deltaFromNow).Humanize(utcDate: true, dateToCompareAgainst: utcNow));
+ Assert.Equal(expectedString, localNow.Add(deltaFromNow).Humanize(utcDate: false, dateToCompareAgainst: localNow));
+ }
+
+ static void VerifyWithDateInjection(string expectedString, TimeSpan deltaFromNow)
+ {
+ var utcNow = new DateTime(2013, 6, 20, 9, 58, 22, DateTimeKind.Utc);
+ var now = new DateTime(2013, 6, 20, 11, 58, 22, DateTimeKind.Local);
+
+ Assert.Equal(expectedString, utcNow.Add(deltaFromNow).Humanize(utcDate: true, dateToCompareAgainst: utcNow));
+ Assert.Equal(expectedString, now.Add(deltaFromNow).Humanize(false, now));
+ }
+
+ public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Tense tense)
+ {
+ var deltaFromNow = new TimeSpan();
+ unit = Math.Abs(unit);
+
+ if (tense == Tense.Past)
+ unit = -unit;
+
+ switch (timeUnit)
+ {
+ case TimeUnit.Second:
+ deltaFromNow = TimeSpan.FromSeconds(unit);
+ break;
+ case TimeUnit.Minute:
+ deltaFromNow = TimeSpan.FromMinutes(unit);
+ break;
+ case TimeUnit.Hour:
+ deltaFromNow = TimeSpan.FromHours(unit);
+ break;
+ case TimeUnit.Day:
+ deltaFromNow = TimeSpan.FromDays(unit);
+ break;
+ case TimeUnit.Month:
+ deltaFromNow = TimeSpan.FromDays(unit*31);
+ break;
+ case TimeUnit.Year:
+ deltaFromNow = TimeSpan.FromDays(unit*366);
+ break;
+ }
+
+ VerifyWithCurrentDate(expectedString, deltaFromNow);
+ VerifyWithDateInjection(expectedString, deltaFromNow);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Humanizer.Tests/DateHumanizeTests.cs b/src/Humanizer.Tests/DateHumanizeTests.cs
index 9ff961f2e..b5892e2b9 100644
--- a/src/Humanizer.Tests/DateHumanizeTests.cs
+++ b/src/Humanizer.Tests/DateHumanizeTests.cs
@@ -1,223 +1,128 @@
-using System;
-using Humanizer.Localisation;
-using Xunit;
+using Humanizer.Localisation;
+using Xunit.Extensions;
namespace Humanizer.Tests
{
public class DateHumanizeTests
{
- static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow)
+ [Theory]
+ [InlineData(1, "one second ago")]
+ [InlineData(10, "10 seconds ago")]
+ [InlineData(59, "59 seconds ago")]
+ [InlineData(60, "a minute ago")]
+ public void SecondsAgo(int seconds, string expected)
{
- var utcNow = DateTime.UtcNow;
- var localNow = DateTime.Now;
-
- // feels like the only way to avoid breaking tests because CPU ticks over is to inject the base date
- Assert.Equal(expectedString, utcNow.Add(deltaFromNow).Humanize(utcDate: true, dateToCompareAgainst: utcNow));
- Assert.Equal(expectedString, localNow.Add(deltaFromNow).Humanize(utcDate: false, dateToCompareAgainst: localNow));
- }
-
- static void VerifyWithDateInjection(string expectedString, TimeSpan deltaFromNow)
- {
- var utcNow = new DateTime(2013, 6, 20, 9, 58, 22, DateTimeKind.Utc);
- var now = new DateTime(2013, 6, 20, 11, 58, 22, DateTimeKind.Local);
-
- Assert.Equal(expectedString, utcNow.Add(deltaFromNow).Humanize(dateToCompareAgainst: utcNow));
- Assert.Equal(expectedString, now.Add(deltaFromNow).Humanize(false, now));
- }
-
- static void Verify(string expectedString, TimeSpan deltaFromNow)
- {
- VerifyWithCurrentDate(expectedString, deltaFromNow);
- VerifyWithDateInjection(expectedString, deltaFromNow);
- }
-
- [Fact]
- public void OneSecondFromNow()
- {
- var oneSecondFromNow = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, TimeUnitTense.Future, count: 1));
- Verify(oneSecondFromNow, new TimeSpan(0, 0, 0, 1));
- }
-
- [Fact]
- public void SecondsFromNow()
- {
- var secsFromNow = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, TimeUnitTense.Future, count: 10)), 10);
- Verify(secsFromNow, new TimeSpan(0, 0, 0, 10));
- }
-
- [Fact]
- public void OneMinuteFromNow()
- {
- var oneMinFromNow = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, TimeUnitTense.Future, count: 1));
- Verify(oneMinFromNow, new TimeSpan(0, 0, 1, 1));
- }
-
- [Fact]
- public void AFewMinutesFromNow()
- {
- var minsFromNow = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, TimeUnitTense.Future, count: 10)), 10);
- Verify(minsFromNow, new TimeSpan(0, 0, 10, 0));
- }
-
- [Fact]
- public void AnHourFromNow()
- {
- var anHourFromNow = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, TimeUnitTense.Future, count: 1));
- Verify(anHourFromNow, new TimeSpan(0, 1, 10, 0));
- }
-
- [Fact]
- public void HoursFromNow()
- {
- var hoursFromNow = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, TimeUnitTense.Future, count: 10)), 10);
- Verify(hoursFromNow, new TimeSpan(0, 10, 0, 0));
- }
-
- [Fact]
- public void Tomorrow()
- {
- var tomorrow = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, TimeUnitTense.Future, count: 1));
- Verify(tomorrow, new TimeSpan(1, 10, 0, 0));
- }
-
- [Fact]
- public void AFewDaysFromNow()
- {
- var daysFromNow = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, TimeUnitTense.Future, count: 10)), 10);
- Verify(daysFromNow, new TimeSpan(10, 1, 0, 0));
- }
-
- [Fact]
- public void OneMonthFromNow()
- {
- var oneMonthFromNow = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, TimeUnitTense.Future, count: 1));
- Verify(oneMonthFromNow, new TimeSpan(31, 1, 0, 0));
- }
-
- [Fact]
- public void AFewMonthsFromNow()
- {
- var monthsFromNow = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, TimeUnitTense.Future, count: 2)), 2);
- Verify(monthsFromNow, new TimeSpan(62, 1, 0, 0));
- }
-
- [Fact]
- public void OneYearFromNowIsNotAccureate()
- {
- var aYearFromNow = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, TimeUnitTense.Future, count: 1));
- Verify(aYearFromNow, new TimeSpan(360, 0, 0, 0));
- }
-
- [Fact]
- public void OneYearFromNow()
- {
- var aYearFromNow = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, TimeUnitTense.Future, count: 1));
- Verify(aYearFromNow, new TimeSpan(400, 0, 0, 0));
- }
-
- [Fact]
- public void FewYearsFromNow()
- {
- var fewYearsFromNow = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, TimeUnitTense.Future, count: 2)), 2);
- Verify(fewYearsFromNow, new TimeSpan(900, 0, 0, 0));
- }
-
- [Fact]
- public void JustNow()
- {
- var now = Resources.GetResource(ResourceKeys.DateHumanize.Now);
- Verify(now, new TimeSpan(0, 0, 0, 0));
- }
-
- [Fact]
- public void OneSecondAgo()
- {
- var aSecAgo = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, TimeUnitTense.Past));
- Verify(aSecAgo, new TimeSpan(0, 0, 0, -1));
- }
-
- [Fact]
- public void SecondsAgo()
- {
- var secondsAgo = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, TimeUnitTense.Past, count: 10)), 10);
- Verify(secondsAgo, new TimeSpan(0, 0, 0, -10));
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
- [Fact]
- public void OneMinuteAgo()
+ [Theory]
+ [InlineData(1, "one second from now")]
+ [InlineData(10, "10 seconds from now")]
+ [InlineData(59, "59 seconds from now")]
+ [InlineData(60, "a minute from now")]
+ public void SecondsFromNow(int seconds, string expected)
{
- var aMinuteAgo = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, TimeUnitTense.Past));
- Verify(aMinuteAgo, new TimeSpan(0, 0, -1, -10));
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}
- [Fact]
- public void AFewMinutesAgo()
+ [Theory]
+ [InlineData(1, "a minute ago")]
+ [InlineData(10, "10 minutes ago")]
+ [InlineData(44, "44 minutes ago")]
+ [InlineData(45, "an hour ago")]
+ [InlineData(119, "an hour ago")]
+ [InlineData(120, "2 hours ago")]
+ public void MinutesAgo(int minutes, string expected)
{
- var minsAgo = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, TimeUnitTense.Past, count: 10)), 10);
- Verify(minsAgo, new TimeSpan(0, 0, -10, 0));
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
- [Fact]
- public void AnHourAgo()
+ [Theory]
+ [InlineData(1, "a minute from now")]
+ [InlineData(10, "10 minutes from now")]
+ [InlineData(44, "44 minutes from now")]
+ [InlineData(45, "an hour from now")]
+ [InlineData(119, "an hour from now")]
+ [InlineData(120, "2 hours from now")]
+ public void MinutesFromNow(int minutes, string expected)
{
- var anHourAgo = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, TimeUnitTense.Past));
- Verify(anHourAgo, new TimeSpan(0, -1, -10, 0));
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}
- [Fact]
- public void HoursAgo()
+ [Theory]
+ [InlineData(1, "an hour ago")]
+ [InlineData(10, "10 hours ago")]
+ [InlineData(23, "23 hours ago")]
+ [InlineData(24, "yesterday")]
+ public void HoursAgo(int hours, string expected)
{
- var hoursAgo = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, TimeUnitTense.Past, count: 10)), 10);
- Verify(hoursAgo, new TimeSpan(0, -10, 0, 0));
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
- [Fact]
- public void Yesterday()
+ [Theory]
+ [InlineData(1, "an hour from now")]
+ [InlineData(10, "10 hours from now")]
+ [InlineData(23, "23 hours from now")]
+ [InlineData(24, "tomorrow")]
+ public void HoursFromNow(int hours, string expected)
{
- var yesterday = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, TimeUnitTense.Past));
- Verify(yesterday, new TimeSpan(-1, -10, 0, 0));
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}
- [Fact]
- public void AFewDaysAgo()
+ [Theory]
+ [InlineData(1, "yesterday")]
+ [InlineData(10, "10 days ago")]
+ [InlineData(28, "28 days ago")]
+ [InlineData(32, "one month ago")]
+ public void DaysAgo(int days, string expected)
{
- var fewDaysAgo = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, TimeUnitTense.Past, count: 10)), 10);
- Verify(fewDaysAgo, new TimeSpan(-10, -1, 0, 0));
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
- [Fact]
- public void OneMonthAgo()
+ [Theory]
+ [InlineData(1, "tomorrow")]
+ [InlineData(10, "10 days from now")]
+ [InlineData(28, "28 days from now")]
+ [InlineData(32, "one month from now")]
+ public void DaysFromNow(int days, string expected)
{
- var aMonthAgo = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, TimeUnitTense.Past));
- Verify(aMonthAgo, new TimeSpan(-31, -1, 0, 0));
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}
- [Fact]
- public void AFewMonthsAgo()
+ [Theory]
+ [InlineData(1, "one month ago")]
+ [InlineData(10, "10 months ago")]
+ [InlineData(11, "11 months ago")]
+ [InlineData(12, "one year ago")]
+ public void MonthsAgo(int months, string expected)
{
- var monthsAgo = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, TimeUnitTense.Past, count: 2)), 2);
- Verify(monthsAgo, new TimeSpan(-62, -1, 0, 0));
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
- [Fact]
- public void OneYearAgoIsNotAccureate()
+ [Theory]
+ [InlineData(1, "one month from now")]
+ [InlineData(10, "10 months from now")]
+ [InlineData(11, "11 months from now")]
+ [InlineData(12, "one year from now")]
+ public void MonthsFromNow(int months, string expected)
{
- var aYearAgo = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, TimeUnitTense.Past));
- Verify(aYearAgo, new TimeSpan(-360, 0, 0, 0));
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}
- [Fact]
- public void OneYearAgo()
+ [Theory]
+ [InlineData(1, "one year ago")]
+ [InlineData(2, "2 years ago")]
+ public void YearsAgo(int years, string expected)
{
- var aYearAgo = Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, TimeUnitTense.Past));
- Verify(aYearAgo, new TimeSpan(-400, 0, 0, 0));
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
- [Fact]
- public void FewYearsAgo()
+ [Theory]
+ [InlineData(1, "one year from now")]
+ [InlineData(2, "2 years from now")]
+ public void YearsFromNow(int years, string expected)
{
- var yearsAgo = string.Format(Resources.GetResource(ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, TimeUnitTense.Past, count: 2)), 2);
- Verify(yearsAgo, new TimeSpan(-900, 0, 0, 0));
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
}
}
diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj
index 5fa5d0369..444ac46d6 100644
--- a/src/Humanizer.Tests/Humanizer.Tests.csproj
+++ b/src/Humanizer.Tests/Humanizer.Tests.csproj
@@ -75,13 +75,14 @@
+
-
+
@@ -100,7 +101,7 @@
-
+
@@ -110,7 +111,7 @@
-
+
@@ -124,7 +125,7 @@
-
+
diff --git a/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs
index 98da12974..00151b5cb 100644
--- a/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs
+++ b/src/Humanizer.Tests/Localisation/ar/DateHumanizeTests.cs
@@ -1,5 +1,4 @@
-using System;
-using Xunit;
+using Humanizer.Localisation;
using Xunit.Extensions;
namespace Humanizer.Tests.Localisation.ar
@@ -16,7 +15,7 @@ public DateHumanizeTests() : base("ar") { }
[InlineData(-11, "منذ 11 يوم")]
public void DaysAgo(int days, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
[Theory]
@@ -26,7 +25,7 @@ public void DaysAgo(int days, string expected)
[InlineData(-11, "منذ 11 ساعة")]
public void HoursAgo(int hours, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
[Theory]
@@ -36,7 +35,7 @@ public void HoursAgo(int hours, string expected)
[InlineData(-11, "منذ 11 دقيقة")]
public void MinutesAgo(int minutes, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
[Theory]
@@ -46,7 +45,7 @@ public void MinutesAgo(int minutes, string expected)
[InlineData(-11, "منذ 11 شهر")]
public void MonthsAgo(int months, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
[Theory]
@@ -56,7 +55,7 @@ public void MonthsAgo(int months, string expected)
[InlineData(-11, "منذ 11 ثانية")]
public void SecondsAgo(int seconds, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
[Theory]
@@ -66,7 +65,7 @@ public void SecondsAgo(int seconds, string expected)
[InlineData(-11, "منذ 11 عام")]
public void YearsAgo(int years, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize());
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
}
}
diff --git a/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs
index 21bd02741..c476954dd 100644
--- a/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs
+++ b/src/Humanizer.Tests/Localisation/cs/DateHumanizeTests.cs
@@ -1,5 +1,4 @@
-using System;
-using Xunit;
+using Humanizer.Localisation;
using Xunit.Extensions;
namespace Humanizer.Tests.Localisation.cs
@@ -19,9 +18,9 @@ public DateHumanizeTests()
[InlineData(5, "za 5 sekund")]
[InlineData(6, "za 6 sekund")]
[InlineData(10, "za 10 sekund")]
- public void SecondsFromNow(int number, string expected)
+ public void SecondsFromNow(int seconds, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddSeconds(number).Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}
[Theory]
@@ -32,9 +31,9 @@ public void SecondsFromNow(int number, string expected)
[InlineData(5, "za 5 minut")]
[InlineData(6, "za 6 minut")]
[InlineData(10, "za 10 minut")]
- public void MinutesFromNow(int number, string expected)
+ public void MinutesFromNow(int minutes, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMinutes(number).Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}
[Theory]
@@ -45,9 +44,9 @@ public void MinutesFromNow(int number, string expected)
[InlineData(5, "za 5 hodin")]
[InlineData(6, "za 6 hodin")]
[InlineData(10, "za 10 hodin")]
- public void HoursFromNow(int number, string expected)
+ public void HoursFromNow(int hours, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddHours(number).Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}
[Theory]
@@ -57,9 +56,9 @@ public void HoursFromNow(int number, string expected)
[InlineData(4, "za 4 dny")]
[InlineData(9, "za 9 dnů")]
[InlineData(10, "za 10 dnů")]
- public void DayFromNow(int number, string expected)
+ public void DayFromNow(int days, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddDays(number).Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}
[Theory]
@@ -70,9 +69,9 @@ public void DayFromNow(int number, string expected)
[InlineData(5, "za 5 měsíců")]
[InlineData(6, "za 6 měsíců")]
[InlineData(10, "za 10 měsíců")]
- public void MonthsFromNow(int number, string expected)
+ public void MonthsFromNow(int months, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMonths(number).Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}
[Theory]
@@ -83,9 +82,9 @@ public void MonthsFromNow(int number, string expected)
[InlineData(5, "za 5 let")]
[InlineData(6, "za 6 let")]
[InlineData(10, "za 10 let")]
- public void YearsFromNow(int number, string expected)
+ public void YearsFromNow(int years, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddYears(number).Humanize());
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
[Theory]
@@ -96,9 +95,9 @@ public void YearsFromNow(int number, string expected)
[InlineData(5, "před 5 sekundami")]
[InlineData(6, "před 6 sekundami")]
[InlineData(10, "před 10 sekundami")]
- public void SecondsAgo(int number, string expected)
+ public void SecondsAgo(int seconds, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddSeconds(-1 * number).Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
[Theory]
@@ -109,9 +108,9 @@ public void SecondsAgo(int number, string expected)
[InlineData(5, "před 5 minutami")]
[InlineData(6, "před 6 minutami")]
[InlineData(10, "před 10 minutami")]
- public void MinutesAgo(int number, string expected)
+ public void MinutesAgo(int minutes, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMinutes(-1 * number).Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
[Theory]
@@ -122,9 +121,9 @@ public void MinutesAgo(int number, string expected)
[InlineData(5, "před 5 hodinami")]
[InlineData(6, "před 6 hodinami")]
[InlineData(10, "před 10 hodinami")]
- public void HoursAgo(int number, string expected)
+ public void HoursAgo(int hours, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddHours(-1 * number).Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
[Theory]
@@ -134,9 +133,9 @@ public void HoursAgo(int number, string expected)
[InlineData(4, "před 4 dny")]
[InlineData(9, "před 9 dny")]
[InlineData(10, "před 10 dny")]
- public void DayAgo(int number, string expected)
+ public void DayAgo(int days, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddDays(-1 * number).Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
[Theory]
@@ -147,9 +146,9 @@ public void DayAgo(int number, string expected)
[InlineData(5, "před 5 měsíci")]
[InlineData(6, "před 6 měsíci")]
[InlineData(10, "před 10 měsíci")]
- public void MonthsAgo(int number, string expected)
+ public void MonthsAgo(int months, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMonths(-1 * number).Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
[Theory]
@@ -160,9 +159,9 @@ public void MonthsAgo(int number, string expected)
[InlineData(5, "před 5 lety")]
[InlineData(6, "před 6 lety")]
[InlineData(10, "před 10 lety")]
- public void YearsAgo(int number, string expected)
+ public void YearsAgo(int years, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddYears(-1 * number).Humanize());
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
}
}
diff --git a/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs
index cef1b60f8..f11917b46 100644
--- a/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs
+++ b/src/Humanizer.Tests/Localisation/de/DateHumanizeTests.cs
@@ -1,5 +1,4 @@
-using System;
-using Xunit;
+using Humanizer.Localisation;
using Xunit.Extensions;
namespace Humanizer.Tests.Localisation.de
@@ -15,15 +14,15 @@ public DateHumanizeTests() : base("de-DE") {}
[InlineData(-1, "gestern")]
public void DaysAgo(int days, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
[Theory]
[InlineData(2, "in 2 Tagen")]
[InlineData(1, "morgen")]
- public void InDays(int days, string expected)
+ public void DaysFromNow(int days, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddDays(days).Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}
[Theory]
@@ -33,15 +32,15 @@ public void InDays(int days, string expected)
[InlineData(-1, "vor einer Stunde")]
public void HoursAgo(int hours, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
[Theory]
[InlineData(2, "in 2 Stunden")]
[InlineData(1, "in einer Stunde")]
- public void InHours(int hours, string expected)
+ public void HoursFromNow(int hours, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddHours(hours).Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}
[Theory]
@@ -51,15 +50,15 @@ public void InHours(int hours, string expected)
[InlineData(-1, "vor einer Minute")]
public void MinutesAgo(int minutes, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
[Theory]
[InlineData(2, "in 2 Minuten")]
[InlineData(1, "in einer Minute")]
- public void InMinutes(int minutes, string expected)
+ public void MinutesFromNow(int minutes, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMinutes(minutes).Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}
[Theory]
@@ -69,15 +68,15 @@ public void InMinutes(int minutes, string expected)
[InlineData(-1, "vor einem Monat")]
public void MonthsAgo(int months, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
[Theory]
[InlineData(2, "in 2 Monaten")]
[InlineData(1, "in einem Monat")]
- public void InMonths(int months, string expected)
+ public void MonthsFromNow(int months, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMonths(months).Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}
[Theory]
@@ -87,15 +86,15 @@ public void InMonths(int months, string expected)
[InlineData(-1, "vor einer Sekunde")]
public void SecondsAgo(int seconds, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
[Theory]
[InlineData(2, "in 2 Sekunden")]
[InlineData(1, "in einer Sekunde")]
- public void InSeconds(int seconds, string expected)
+ public void SecondsFromNow(int seconds, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddSeconds(seconds).Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}
[Theory]
@@ -105,15 +104,15 @@ public void InSeconds(int seconds, string expected)
[InlineData(-1, "vor einem Jahr")]
public void YearsAgo(int years, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize());
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
[Theory]
[InlineData(2, "in 2 Jahren")]
[InlineData(1, "in einem Jahr")]
- public void InYears(int years, string expected)
+ public void YearsFromNow(int years, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddYears(years).Humanize());
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
}
}
diff --git a/src/Humanizer.Tests/Localisation/DateHumanizeTests.fi-FI.cs b/src/Humanizer.Tests/Localisation/fi-FI/DateHumanizeTests.cs
similarity index 68%
rename from src/Humanizer.Tests/Localisation/DateHumanizeTests.fi-FI.cs
rename to src/Humanizer.Tests/Localisation/fi-FI/DateHumanizeTests.cs
index 3ee83fb58..99d9445f1 100644
--- a/src/Humanizer.Tests/Localisation/DateHumanizeTests.fi-FI.cs
+++ b/src/Humanizer.Tests/Localisation/fi-FI/DateHumanizeTests.cs
@@ -1,12 +1,11 @@
-using System;
-using Xunit;
+using Humanizer.Localisation;
using Xunit.Extensions;
-namespace Humanizer.Tests.Localisation
+namespace Humanizer.Tests.Localisation.fiFI
{
- public class DateHumanizeTests_fiFI : AmbientCulture
+ public class DateHumanizeTests : AmbientCulture
{
- public DateHumanizeTests_fiFI()
+ public DateHumanizeTests()
: base("fi-Fi")
{
}
@@ -18,8 +17,7 @@ public DateHumanizeTests_fiFI()
[InlineData(-1, "eilen")]
public void DaysAgo(int days, string expected)
{
- var date = DateTime.UtcNow.AddDays(days);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
[Theory]
@@ -29,8 +27,7 @@ public void DaysAgo(int days, string expected)
[InlineData(-1, "tunti sitten")]
public void HoursAgo(int hours, string expected)
{
- var date = DateTime.UtcNow.AddHours(hours);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
[Theory]
@@ -40,8 +37,7 @@ public void HoursAgo(int hours, string expected)
[InlineData(-1, "minuutti sitten")]
public void MinutesAgo(int minutes, string expected)
{
- var date = DateTime.UtcNow.AddMinutes(minutes);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
[Theory]
@@ -51,8 +47,7 @@ public void MinutesAgo(int minutes, string expected)
[InlineData(-1, "kuukausi sitten")]
public void MonthsAgo(int months, string expected)
{
- var date = DateTime.UtcNow.AddMonths(months);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
[Theory]
@@ -62,8 +57,7 @@ public void MonthsAgo(int months, string expected)
[InlineData(-1, "sekuntti sitten")]
public void SecondsAgo(int seconds, string expected)
{
- var date = DateTime.UtcNow.AddSeconds(seconds);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
[Theory]
@@ -73,8 +67,7 @@ public void SecondsAgo(int seconds, string expected)
[InlineData(-1, "vuosi sitten")]
public void YearsAgo(int years, string expected)
{
- var date = DateTime.UtcNow.AddYears(years);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
}
}
diff --git a/src/Humanizer.Tests/Localisation/DateHumanizeTests.nb-NO.cs b/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs
similarity index 67%
rename from src/Humanizer.Tests/Localisation/DateHumanizeTests.nb-NO.cs
rename to src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs
index 9cfc5ff0b..b8ac85b51 100644
--- a/src/Humanizer.Tests/Localisation/DateHumanizeTests.nb-NO.cs
+++ b/src/Humanizer.Tests/Localisation/nb-NO/DateHumanizeTests.cs
@@ -1,12 +1,11 @@
-using System;
-using Xunit;
+using Humanizer.Localisation;
using Xunit.Extensions;
-namespace Humanizer.Tests.Localisation
+namespace Humanizer.Tests.Localisation.nbNO
{
- public class DateHumanizeTests_nbNO : AmbientCulture
+ public class DateHumanizeTests : AmbientCulture
{
- public DateHumanizeTests_nbNO()
+ public DateHumanizeTests()
: base("nb-NO")
{
}
@@ -18,8 +17,7 @@ public DateHumanizeTests_nbNO()
[InlineData(-1, "i går")]
public void DaysAgo(int days, string expected)
{
- var date = DateTime.UtcNow.AddDays(days);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
[Theory]
@@ -29,8 +27,7 @@ public void DaysAgo(int days, string expected)
[InlineData(-1, "en time siden")]
public void HoursAgo(int hours, string expected)
{
- var date = DateTime.UtcNow.AddHours(hours);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
[Theory]
@@ -40,8 +37,7 @@ public void HoursAgo(int hours, string expected)
[InlineData(-1, "et minutt siden")]
public void MinutesAgo(int minutes, string expected)
{
- var date = DateTime.UtcNow.AddMinutes(minutes);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
[Theory]
@@ -51,8 +47,7 @@ public void MinutesAgo(int minutes, string expected)
[InlineData(-1, "en måned siden")]
public void MonthsAgo(int months, string expected)
{
- var date = DateTime.UtcNow.AddMonths(months);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
[Theory]
@@ -62,8 +57,7 @@ public void MonthsAgo(int months, string expected)
[InlineData(-1, "et sekund siden")]
public void SecondsAgo(int seconds, string expected)
{
- var date = DateTime.UtcNow.AddSeconds(seconds);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
[Theory]
@@ -73,8 +67,7 @@ public void SecondsAgo(int seconds, string expected)
[InlineData(-1, "et år siden")]
public void YearsAgo(int years, string expected)
{
- var date = DateTime.UtcNow.AddYears(years);
- Assert.Equal(expected, date.Humanize());
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
}
}
diff --git a/src/Humanizer.Tests/Localisation/DateHumanizeTests.ro-RO.cs b/src/Humanizer.Tests/Localisation/ro-Ro/DateHumanizeTests.cs
similarity index 94%
rename from src/Humanizer.Tests/Localisation/DateHumanizeTests.ro-RO.cs
rename to src/Humanizer.Tests/Localisation/ro-Ro/DateHumanizeTests.cs
index 9047d13a9..1dcbd091d 100644
--- a/src/Humanizer.Tests/Localisation/DateHumanizeTests.ro-RO.cs
+++ b/src/Humanizer.Tests/Localisation/ro-Ro/DateHumanizeTests.cs
@@ -1,16 +1,16 @@
using System;
using Xunit;
-namespace Humanizer.Tests.Localisation
+namespace Humanizer.Tests.Localisation.roRo
{
///
/// Test that for values bigger than 19 "de" is added between the numeral
/// and the time unit: http://ebooks.unibuc.ro/filologie/NForascu-DGLR/numerale.htm.
/// There is no test for months since there are only 12 of them in a year.
///
- public class RomanianDateHumanizeTests : AmbientCulture
+ public class DateHumanizeTests : AmbientCulture
{
- public RomanianDateHumanizeTests() : base("ro-RO")
+ public DateHumanizeTests() : base("ro-RO")
{
}
diff --git a/src/Humanizer.Tests/Localisation/DateHumanizeTests.ru-RU.cs b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs
similarity index 77%
rename from src/Humanizer.Tests/Localisation/DateHumanizeTests.ru-RU.cs
rename to src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs
index aaf040fd6..4d9d207cc 100644
--- a/src/Humanizer.Tests/Localisation/DateHumanizeTests.ru-RU.cs
+++ b/src/Humanizer.Tests/Localisation/ru-RU/DateHumanizeTests.cs
@@ -1,12 +1,11 @@
-using System;
-using Xunit;
+using Humanizer.Localisation;
using Xunit.Extensions;
-namespace Humanizer.Tests.Localisation
+namespace Humanizer.Tests.Localisation.ruRU
{
- public class RussianDateHumanizeTests : AmbientCulture
+ public class DateHumanizeTests : AmbientCulture
{
- public RussianDateHumanizeTests() : base("ru-RU")
+ public DateHumanizeTests() : base("ru-RU")
{
}
@@ -27,10 +26,9 @@ public RussianDateHumanizeTests() : base("ru-RU")
[InlineData(24, "24 секунды назад")]
[InlineData(25, "25 секунд назад")]
[InlineData(40, "40 секунд назад")]
- public void NSecondsAgo(int number, string expected)
+ public void SecondsAgo(int seconds, string expected)
{
- var humanize = DateTime.UtcNow.AddSeconds(-1 * number).Humanize();
- Assert.Equal(expected, humanize);
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
[Theory]
@@ -50,10 +48,9 @@ public void NSecondsAgo(int number, string expected)
[InlineData(24, "24 минуты назад")]
[InlineData(25, "25 минут назад")]
[InlineData(40, "40 минут назад")]
- public void NMinutesAgo(int number, string expected)
+ public void MinutesAgo(int minutes, string expected)
{
- var humanize = DateTime.UtcNow.AddMinutes(-1 * number).Humanize();
- Assert.Equal(expected, humanize);
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
[Theory]
@@ -70,10 +67,9 @@ public void NMinutesAgo(int number, string expected)
[InlineData(21, "21 час назад")]
[InlineData(22, "22 часа назад")]
[InlineData(23, "23 часа назад")]
- public void NHoursAgo(int number, string expected)
+ public void HoursAgo(int hours, string expected)
{
- var humanize = DateTime.UtcNow.AddHours(-1 * number).Humanize();
- Assert.Equal(expected, humanize);
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
[Theory]
@@ -92,10 +88,9 @@ public void NHoursAgo(int number, string expected)
[InlineData(23, "23 дня назад")]
[InlineData(24, "24 дня назад")]
[InlineData(25, "25 дней назад")]
- public void NDaysAgo(int number, string expected)
+ public void DaysAgo(int days, string expected)
{
- var humanize = DateTime.UtcNow.Date.AddDays(-1 * number).Humanize();
- Assert.Equal(expected, humanize);
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
[Theory]
@@ -107,10 +102,9 @@ public void NDaysAgo(int number, string expected)
[InlineData(6, "6 месяцев назад")]
[InlineData(10, "10 месяцев назад")]
[InlineData(11, "11 месяцев назад")]
- public void NMonthsAgo(int number, string expected)
+ public void MonthsAgo(int months, string expected)
{
- var humanize = DateTime.UtcNow.Date.AddMonths(-1 * number).Humanize();
- Assert.Equal(expected, humanize);
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
[Theory]
@@ -128,10 +122,9 @@ public void NMonthsAgo(int number, string expected)
[InlineData(121, "121 год назад")]
[InlineData(222, "222 года назад")]
[InlineData(325, "325 лет назад")]
- public void NYearsAgo(int number, string expected)
+ public void YearsAgo(int years, string expected)
{
- var humanize = DateTime.UtcNow.Date.AddYears(-1 * number).Humanize();
- Assert.Equal(expected, humanize);
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}
}
}
diff --git a/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs
index 9ce873cef..0842d4175 100644
--- a/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs
+++ b/src/Humanizer.Tests/Localisation/sk/DateHumanizeTests.cs
@@ -1,5 +1,4 @@
-using System;
-using Xunit;
+using Humanizer.Localisation;
using Xunit.Extensions;
namespace Humanizer.Tests.Localisation.sk
@@ -19,9 +18,9 @@ public DateHumanizeTests()
[InlineData(5, "o 5 sekúnd")]
[InlineData(6, "o 6 sekúnd")]
[InlineData(10, "o 10 sekúnd")]
- public void SecondsFromNow(int number, string expected)
- {
- Assert.Equal(expected, DateTime.UtcNow.AddSeconds(number).Humanize());
+ public void SecondsFromNow(int seconds, string expected)
+ {
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}
[Theory]
@@ -32,9 +31,9 @@ public void SecondsFromNow(int number, string expected)
[InlineData(5, "o 5 minút")]
[InlineData(6, "o 6 minút")]
[InlineData(10, "o 10 minút")]
- public void MinutesFromNow(int number, string expected)
- {
- Assert.Equal(expected, DateTime.UtcNow.AddMinutes(number).Humanize());
+ public void MinutesFromNow(int minutes, string expected)
+ {
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}
[Theory]
@@ -45,11 +44,11 @@ public void MinutesFromNow(int number, string expected)
[InlineData(5, "o 5 hodín")]
[InlineData(6, "o 6 hodín")]
[InlineData(10, "o 10 hodín")]
- public void HoursFromNow(int number, string expected)
- {
- Assert.Equal(expected, DateTime.UtcNow.AddHours(number).Humanize());
+ public void HoursFromNow(int hours, string expected)
+ {
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}
-
+
[Theory]
[InlineData(1, "zajtra")]
[InlineData(2, "o 2 dni")]
@@ -57,9 +56,9 @@ public void HoursFromNow(int number, string expected)
[InlineData(4, "o 4 dni")]
[InlineData(9, "o 9 dní")]
[InlineData(10, "o 10 dní")]
- public void DayFromNow(int number, string expected)
- {
- Assert.Equal(expected, DateTime.UtcNow.AddDays(number).Humanize());
+ public void DaysFromNow(int days, string expected)
+ {
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}
[Theory]
@@ -70,9 +69,9 @@ public void DayFromNow(int number, string expected)
[InlineData(5, "o 5 mesiacov")]
[InlineData(6, "o 6 mesiacov")]
[InlineData(10, "o 10 mesiacov")]
- public void MonthsFromNow(int number, string expected)
- {
- Assert.Equal(expected, DateTime.UtcNow.AddMonths(number).Humanize());
+ public void MonthsFromNow(int months, string expected)
+ {
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}
[Theory]
@@ -83,9 +82,9 @@ public void MonthsFromNow(int number, string expected)
[InlineData(5, "o 5 rokov")]
[InlineData(6, "o 6 rokov")]
[InlineData(10, "o 10 rokov")]
- public void YearsFromNow(int number, string expected)
- {
- Assert.Equal(expected, DateTime.UtcNow.AddYears(number).Humanize());
+ public void YearsFromNow(int years, string expected)
+ {
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}
[Theory]
@@ -96,9 +95,9 @@ public void YearsFromNow(int number, string expected)
[InlineData(5, "pred 5 sekundami")]
[InlineData(6, "pred 6 sekundami")]
[InlineData(10, "pred 10 sekundami")]
- public void SecondsAgo(int number, string expected)
+ public void SecondsAgo(int seconds, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddSeconds(-1*number).Humanize());
+ DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}
[Theory]
@@ -109,9 +108,9 @@ public void SecondsAgo(int number, string expected)
[InlineData(5, "pred 5 minútami")]
[InlineData(6, "pred 6 minútami")]
[InlineData(10, "pred 10 minútami")]
- public void MinutesAgo(int number, string expected)
+ public void MinutesAgo(int minutes, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMinutes(-1*number).Humanize());
+ DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}
[Theory]
@@ -122,9 +121,9 @@ public void MinutesAgo(int number, string expected)
[InlineData(5, "pred 5 hodinami")]
[InlineData(6, "pred 6 hodinami")]
[InlineData(10, "pred 10 hodinami")]
- public void HoursAgo(int number, string expected)
+ public void HoursAgo(int hours, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddHours(-1*number).Humanize());
+ DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}
[Theory]
@@ -134,9 +133,9 @@ public void HoursAgo(int number, string expected)
[InlineData(4, "pred 4 dňami")]
[InlineData(9, "pred 9 dňami")]
[InlineData(10, "pred 10 dňami")]
- public void DayAgo(int number, string expected)
+ public void DaysAgo(int days, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddDays(-1*number).Humanize());
+ DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}
[Theory]
@@ -147,9 +146,9 @@ public void DayAgo(int number, string expected)
[InlineData(5, "pred 5 mesiacmi")]
[InlineData(6, "pred 6 mesiacmi")]
[InlineData(10, "pred 10 mesiacmi")]
- public void MonthsAgo(int number, string expected)
+ public void MonthsAgo(int months, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddMonths(-1*number).Humanize());
+ DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}
[Theory]
@@ -160,9 +159,9 @@ public void MonthsAgo(int number, string expected)
[InlineData(5, "pred 5 rokmi")]
[InlineData(6, "pred 6 rokmi")]
[InlineData(10, "pred 10 rokmi")]
- public void YearsAgo(int number, string expected)
+ public void YearsAgo(int years, string expected)
{
- Assert.Equal(expected, DateTime.UtcNow.AddYears(-1*number).Humanize());
- }
+ DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
+ }
}
}
diff --git a/src/Humanizer.Tests/ResourceKeyTests.cs b/src/Humanizer.Tests/ResourceKeyTests.cs
index c0c541a9a..d75b17f39 100644
--- a/src/Humanizer.Tests/ResourceKeyTests.cs
+++ b/src/Humanizer.Tests/ResourceKeyTests.cs
@@ -40,40 +40,40 @@ public static IEnumerable