diff --git a/src/Humanizer.Tests.Shared/OrdinalizeTests.cs b/src/Humanizer.Tests.Shared/OrdinalizeTests.cs index 56225f9b9..0b15325d2 100644 --- a/src/Humanizer.Tests.Shared/OrdinalizeTests.cs +++ b/src/Humanizer.Tests.Shared/OrdinalizeTests.cs @@ -1,4 +1,5 @@ using System.Globalization; + using Xunit; namespace Humanizer.Tests @@ -6,7 +7,6 @@ namespace Humanizer.Tests [UseCulture("en-US")] public class OrdinalizeTests { - [Theory] [InlineData("0", "0th")] [InlineData("1", "1st")] @@ -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)); + } } }