Skip to content
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

Hungarian localization and tests #179

Closed
wants to merge 12 commits into from
3 changes: 2 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
- [#186](https://github.com/Mehdik/Humanizer/pull/186): Refactored 'ToOrdinalWords` to use existing `NumberToWordsExtension` to prepare for Ordinal localization
[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master)
- [#193](https://github.com/Mehdik/Humanizer/pull/193): Fixed the NullException error on DateTime.Humanize

[Commits](https://github.com/MehdiK/Humanizer/compare/v1.20.2...master)
- [#179](https://github.com/MehdiK/Humanizer/pull/179): Adding Hungarian localisation

###v1.20.2 - 2014-04-11
- [#171](https://github.com/MehdiK/Humanizer/pull/171): T4-Template fix: Using EnglishNumberToWordsConverter instead of 'ToWords()' while dogfooding the template with the library.
Expand All @@ -13,6 +13,7 @@
- [#172](https://github.com/MehdiK/Humanizer/pull/172): Added Polish translation for ToWords
- [#184](https://github.com/Mehdik/Humanizer/pull/184): Fixed spelling error with forth/fourth in EnglishNumberToWordsConverter


[Commits](https://github.com/MehdiK/Humanizer/compare/v1.19.1...v1.20.2)

###v1.19.1 - 2014-04-10
Expand Down
2 changes: 2 additions & 0 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
<Compile Include="Localisation\invariant\NumberToWordsTests.cs" />
<Compile Include="Localisation\invariant\ToQuantityTests.cs" />
<Compile Include="Localisation\es\NumberToWordsTests.cs" />
<Compile Include="Localisation\hu\DateHumanizeTests.cs" />
<Compile Include="Localisation\hu\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\nb-NO\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pl\DateHumanizeTests.cs" />
<Compile Include="Localisation\pl\NumberToWordsTests.cs" />
Expand Down
110 changes: 110 additions & 0 deletions src/Humanizer.Tests/Localisation/hu/DateHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using Humanizer.Localisation;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.hu
{
public class DateHumanizeTests : AmbientCulture
{
public DateHumanizeTests()
: base("hu-HU")
{
}

[Theory]
[InlineData(1, "egy másodperce")]
[InlineData(10, "10 másodperce")]
public void SecondsAgo(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past);
}

[Theory]
[InlineData(1, "egy másodperc múlva")]
[InlineData(10, "10 másodperc múlva")]
public void SecondsFromNow(int seconds, string expected)
{
DateHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future);
}

[Theory]
[InlineData(1, "egy perce")]
[InlineData(10, "10 perce")]
public void MinutesAgo(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past);
}

[Theory]
[InlineData(1, "egy perc múlva")]
[InlineData(10, "10 perc múlva")]
public void MinutesFromNow(int minutes, string expected)
{
DateHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future);
}

[Theory]
[InlineData(1, "egy órája")]
[InlineData(10, "10 órája")]
public void HoursAgo(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past);
}

[Theory]
[InlineData(1, "egy óra múlva")]
[InlineData(10, "10 óra múlva")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future);
}

[Theory]
[InlineData(1, "tegnap")]
[InlineData(10, "10 napja")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for checking multiple values. Just check it for 1 and 2. This applies to all the tests you've written.

public void DaysAgo(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past);
}

[Theory]
[InlineData(1, "holnap")]
[InlineData(10, "10 nap múlva")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
}

[Theory]
[InlineData(1, "egy hónapja")]
[InlineData(10, "10 hónapja")]
public void MonthsAgo(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past);
}

[Theory]
[InlineData(1, "egy hónap múlva")]
[InlineData(10, "10 hónap múlva")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
}

[Theory]
[InlineData(1, "egy éve")]
[InlineData(2, "2 éve")]
public void YearsAgo(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past);
}

[Theory]
[InlineData(1, "egy év múlva")]
[InlineData(2, "2 év múlva")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
}

}
}
100 changes: 100 additions & 0 deletions src/Humanizer.Tests/Localisation/hu/TimeSpanHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.hu
{
public class TimeSpanHumanizeTests : AmbientCulture
{
public TimeSpanHumanizeTests() : base("hu-HU") { }

[Theory]
[InlineData(14, "2 hét")]
[InlineData(7, "1 hét")]
public void Weeks(int days, string expected)
{
var actual = TimeSpan.FromDays(days).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 nap")]
[InlineData(1, "1 nap")]
public void Days(int days, string expected)
{
var actual = TimeSpan.FromDays(days).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 óra")]
[InlineData(1, "1 óra")]
public void Hours(int hours, string expected)
{
var actual = TimeSpan.FromHours(hours).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 perc")]
[InlineData(1, "1 perc")]
public void Minutes(int minutes, string expected)
{
var actual = TimeSpan.FromMinutes(minutes).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(2, "2 másodperc")]
[InlineData(1, "1 másodperc")]
public void Seconds(int seconds, string expected)
{
var actual = TimeSpan.FromSeconds(seconds).Humanize();
Assert.Equal(expected, actual);
}

[Theory]
[InlineData(0, 3, "nincs idő")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this test. This has been covered by the English test and the tests you wrote above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is still here! o_O

[InlineData(0, 2, "nincs idő")]
[InlineData(10, 2, "10 ezredmásodperc")]
[InlineData(1400, 2, "1 másodperc, 400 ezredmásodperc")]
[InlineData(2500, 2, "2 másodperc, 500 ezredmásodperc")]
[InlineData(120000, 2, "2 perc")]
[InlineData(62000, 2, "1 perc, 2 másodperc")]
[InlineData(62020, 2, "1 perc, 2 másodperc")]
[InlineData(62020, 3, "1 perc, 2 másodperc, 20 ezredmásodperc")]
[InlineData(3600020, 4, "1 óra, 20 ezredmásodperc")]
[InlineData(3600020, 3, "1 óra, 20 ezredmásodperc")]
[InlineData(3600020, 2, "1 óra, 20 ezredmásodperc")]
[InlineData(3600020, 1, "1 óra")]
[InlineData(3603001, 2, "1 óra, 3 másodperc")]
[InlineData(3603001, 3, "1 óra, 3 másodperc, 1 ezredmásodperc")]
[InlineData(86400000, 3, "1 nap")]
[InlineData(86400000, 2, "1 nap")]
[InlineData(86400000, 1, "1 nap")]
[InlineData(86401000, 1, "1 nap")]
[InlineData(86401000, 2, "1 nap, 1 másodperc")]
[InlineData(86401200, 2, "1 nap, 1 másodperc")]
[InlineData(86401200, 3, "1 nap, 1 másodperc, 200 ezredmásodperc")]
[InlineData(1296000000, 1, "2 hét")]
[InlineData(1296000000, 2, "2 hét, 1 nap")]
[InlineData(1299600000, 2, "2 hét, 1 nap")]
[InlineData(1299600000, 3, "2 hét, 1 nap, 1 óra")]
[InlineData(1299630020, 3, "2 hét, 1 nap, 1 óra")]
[InlineData(1299630020, 4, "2 hét, 1 nap, 1 óra, 30 másodperc")]
[InlineData(1299630020, 5, "2 hét, 1 nap, 1 óra, 30 másodperc, 20 ezredmásodperc")]
public void TimeSpanWithPrecesion(int milliseconds, int precesion, string expected)
{
var actual = TimeSpan.FromMilliseconds(milliseconds).Humanize(precesion);
Assert.Equal(expected, actual);
}

[Fact]
public void NoTime()
{
var noTime = TimeSpan.Zero;
var actual = noTime.Humanize();
Assert.Equal("nincs idő", actual);
}
}
}
1 change: 1 addition & 0 deletions src/Humanizer/Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.da.resx" />
<EmbeddedResource Include="Properties\Resources.hu.resx" />
<EmbeddedResource Include="Properties\Resources.pl.resx" />
<EmbeddedResource Include="Properties\Resources.cs.resx" />
<EmbeddedResource Include="Properties\Resources.de.resx" />
Expand Down
Loading