From dc90d4e1bd7c37c7b387773081b506e45933f524 Mon Sep 17 00:00:00 2001 From: ivanst-stoyanov Date: Fri, 11 Apr 2014 14:44:31 +0300 Subject: [PATCH] Added Bulgarian localization, date and timespan tests --- src/Humanizer.Tests/Humanizer.Tests.csproj | 2 + .../Localisation/bg/DateHumanizeTests.cs | 115 +++++++++ .../Localisation/bg/TimeSpanHumanizeTests.cs | 66 +++++ src/Humanizer/Humanizer.csproj | 1 + src/Humanizer/Properties/Resources.bg.resx | 234 ++++++++++++++++++ 5 files changed, 418 insertions(+) create mode 100644 src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs create mode 100644 src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs create mode 100644 src/Humanizer/Properties/Resources.bg.resx diff --git a/src/Humanizer.Tests/Humanizer.Tests.csproj b/src/Humanizer.Tests/Humanizer.Tests.csproj index 13513efe2..554611345 100644 --- a/src/Humanizer.Tests/Humanizer.Tests.csproj +++ b/src/Humanizer.Tests/Humanizer.Tests.csproj @@ -76,6 +76,8 @@ + + diff --git a/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs new file mode 100644 index 000000000..725cea72f --- /dev/null +++ b/src/Humanizer.Tests/Localisation/bg/DateHumanizeTests.cs @@ -0,0 +1,115 @@ +using Humanizer.Localisation; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.bg +{ + public class DateHumanizeTests : AmbientCulture + { + public DateHumanizeTests() : base("bg-BG") + { + } + + [Theory] + [InlineData(1, "преди секунда")] + [InlineData(2, "преди 2 секунди")] + public void SecondsAgo(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); + } + + [Theory] + [InlineData(1, "след секунда")] + [InlineData(2, "след 2 секунди")] + public void SecondsFromNow(int seconds, string expected) + { + DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); + } + + [Theory] + [InlineData(1, "преди минута")] + [InlineData(2, "преди 2 минути")] + public void MinutesAgo(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); + } + + [Theory] + [InlineData(1, "след минута")] + [InlineData(2, "след 2 минути")] + public void MinutesFromNow(int minutes, string expected) + { + DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); + } + + [Theory] + [InlineData(1, "преди час")] + [InlineData(2, "преди 2 часа")] + public void HoursAgo(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); + } + + [Theory] + [InlineData(1, "след час")] + [InlineData(2, "след 2 часа")] + public void HoursFromNow(int hours, string expected) + { + DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); + } + + [Theory] + [InlineData(1, "вчера")] + [InlineData(2, "преди 2 дена")] + public void DaysAgo(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); + } + + [Theory] + [InlineData(1, "утре")] + [InlineData(2, "след 2 дена")] + public void DaysFromNow(int days, string expected) + { + DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); + } + + [Theory] + [InlineData(1, "преди месец")] + [InlineData(2, "преди 2 месеца")] + public void MonthsAgo(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); + } + + [Theory] + [InlineData(1, "след месец")] + [InlineData(2, "след 2 месеца")] + public void MonthsFromNow(int months, string expected) + { + DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); + } + + [Theory] + [InlineData(1, "преди година")] + [InlineData(2, "преди 2 години")] + public void YearsAgo(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); + } + + [Theory] + [InlineData(1, "след година")] + [InlineData(2, "след 2 години")] + public void YearsFromNow(int years, string expected) + { + DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); + } + + [Fact] + public void Now() + { + DateHumanize.Verify("сега", 0, TimeUnit.Day, Tense.Past); + } + } +} \ No newline at end of file diff --git a/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs b/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs new file mode 100644 index 000000000..3c1d3fe21 --- /dev/null +++ b/src/Humanizer.Tests/Localisation/bg/TimeSpanHumanizeTests.cs @@ -0,0 +1,66 @@ +using System; +using Xunit; +using Xunit.Extensions; + +namespace Humanizer.Tests.Localisation.bg +{ + public class TimeSpanHumanizeTests : AmbientCulture + { + public TimeSpanHumanizeTests() : base("bg-BG") { } + + [Theory] + [InlineData(7, "една седмица")] + [InlineData(14, "2 седмици")] + public void Weeks(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "един ден")] + [InlineData(2, "2 дена")] + public void Days(int days, string expected) + { + Assert.Equal(expected, TimeSpan.FromDays(days).Humanize()); + } + + [Theory] + [InlineData(1, "един час")] + [InlineData(2, "2 часа")] + public void Hours(int hours, string expected) + { + Assert.Equal(expected, TimeSpan.FromHours(hours).Humanize()); + } + + [Theory] + [InlineData(1, "една минута")] + [InlineData(2, "2 минути")] + public void Minutes(int minutes, string expected) + { + Assert.Equal(expected, TimeSpan.FromMinutes(minutes).Humanize()); + } + + [Theory] + [InlineData(1, "една секунда")] + [InlineData(2, "2 секунди")] + public void Seconds(int seconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromSeconds(seconds).Humanize()); + } + + [Theory] + [InlineData(1, "една милисекунда")] + [InlineData(2, "2 милисекунди")] + public void Milliseconds(int milliseconds, string expected) + { + Assert.Equal(expected, TimeSpan.FromMilliseconds(milliseconds).Humanize()); + } + + [Fact] + public void NoTime() + { + // This one doesn't make a lot of sense but ... w/e + Assert.Equal("няма време", TimeSpan.Zero.Humanize()); + } + } +} \ No newline at end of file diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj index efb54f5d9..adc0c742a 100644 --- a/src/Humanizer/Humanizer.csproj +++ b/src/Humanizer/Humanizer.csproj @@ -153,6 +153,7 @@ + diff --git a/src/Humanizer/Properties/Resources.bg.resx b/src/Humanizer/Properties/Resources.bg.resx new file mode 100644 index 000000000..585db32a6 --- /dev/null +++ b/src/Humanizer/Properties/Resources.bg.resx @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + преди секунда + + + преди {0} секунди + + + преди минута + + + преди {0} минути + + + преди час + + + преди {0} часа + + + вчера + + + преди {0} дена + + + преди месец + + + преди {0} месеца + + + преди година + + + преди {0} години + + + {0} дена + + + {0} часа + + + {0} милисекунди + + + {0} минути + + + {0} секунди + + + един ден + + + един час + + + една милисекунда + + + една минута + + + една секунда + + + няма време + + + {0} седмици + + + една седмица + + + след {0} дена + + + след {0} часа + + + след {0} минути + + + след {0} месеца + + + след {0} секунди + + + след {0} години + + + сега + + + утре + + + след час + + + след минута + + + след месец + + + след секунда + + + след година + +