Skip to content

Commit

Permalink
Add Ordinalizer tests of public API new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Serrano committed Jan 27, 2022
1 parent 059745d commit ef9133d
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/Humanizer.Tests.Shared/OrdinalizeTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Globalization;

using Xunit;

namespace Humanizer.Tests
{
[UseCulture("en-US")]
public class OrdinalizeTests
{

[Theory]
[InlineData("0", "0th")]
[InlineData("1", "1st")]
Expand Down Expand Up @@ -138,5 +138,36 @@ public void OrdinalizeStringWithOverridenGenderIsImmaterial(string number)
var feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine, culture);
Assert.Equal(masculineOrdinalized, feminineOrdinalized);
}

[Theory]
[InlineData(1, WordForm.Normal, "es-ES", "1.º")]
[InlineData(1, WordForm.Abbreviation, "es-ES", "1.er")]
[InlineData(1, WordForm.Normal, "en-US", "1st")]
[InlineData(1, WordForm.Abbreviation, "en-US", "1st")]
public void OrdinalizeNumberWithOverridenCultureAndSpecificForm(int number, WordForm wordForm, string cultureName, string expected)
{
var culture = new CultureInfo(cultureName);
Assert.Equal(expected, number.Ordinalize(culture, wordForm));
Assert.Equal(expected, number.ToString(culture).Ordinalize(culture, wordForm));
}

[Theory]
[InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "es-ES", "1.º")]
[InlineData(1, WordForm.Abbreviation, GrammaticalGender.Masculine, "es-ES", "1.er")]
[InlineData(1, WordForm.Normal, GrammaticalGender.Feminine, "es-ES", "1.ª")]
[InlineData(1, WordForm.Abbreviation, GrammaticalGender.Feminine, "es-ES", "1.ª")]
[InlineData(1, WordForm.Normal, GrammaticalGender.Masculine, "en-US", "1st")]
[InlineData(1, WordForm.Normal, GrammaticalGender.Feminine, "en-US", "1st")]
public void OrdinalizeNumberWithOverridenCultureAndGenderAndForm(
int number,
WordForm wordForm,
GrammaticalGender gender,
string cultureName,
string expected)
{
var culture = new CultureInfo(cultureName);
Assert.Equal(expected, number.Ordinalize(gender, culture, wordForm));
Assert.Equal(expected, number.ToString(culture).Ordinalize(gender, culture, wordForm));
}
}
}

0 comments on commit ef9133d

Please sign in to comment.