diff --git a/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs
index 0fb9a4483..c2c6f56bc 100644
--- a/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs
+++ b/src/Humanizer.Tests/Localisation/es/OrdinalizeTests.cs
@@ -63,7 +63,7 @@ public void OrdinalizeStringFeminine(string number, string ordinalized)
[InlineData(102, "102º")]
[InlineData(103, "103º")]
[InlineData(1001, "1001º")]
- public void OrdanizeNumber(int number, string ordinalized)
+ public void OrdinalizeNumber(int number, string ordinalized)
{
Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized);
}
@@ -83,7 +83,7 @@ public void OrdanizeNumber(int number, string ordinalized)
[InlineData(102, "102ª")]
[InlineData(103, "103ª")]
[InlineData(1001, "1001ª")]
- public void OrdanizeNumberFeminine(int number, string ordinalized)
+ public void OrdinalizeNumberFeminine(int number, string ordinalized)
{
Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized);
}
diff --git a/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs b/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs
index eafd324d9..e9815af35 100644
--- a/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs
+++ b/src/Humanizer.Tests/Localisation/pt-BR/OrdinalizeTests.cs
@@ -63,7 +63,7 @@ public void OrdinalizeStringFeminine(string number, string ordinalized)
[InlineData(102, "102º")]
[InlineData(103, "103º")]
[InlineData(1001, "1001º")]
- public void OrdanizeNumber(int number, string ordinalized)
+ public void OrdinalizeNumber(int number, string ordinalized)
{
Assert.Equal(number.Ordinalize(GrammaticalGender.Masculine), ordinalized);
}
@@ -83,7 +83,7 @@ public void OrdanizeNumber(int number, string ordinalized)
[InlineData(102, "102ª")]
[InlineData(103, "103ª")]
[InlineData(1001, "1001ª")]
- public void OrdanizeNumberFeminine(int number, string ordinalized)
+ public void OrdinalizeNumberFeminine(int number, string ordinalized)
{
Assert.Equal(number.Ordinalize(GrammaticalGender.Feminine), ordinalized);
}
diff --git a/src/Humanizer.Tests/OrdinalizeTests.cs b/src/Humanizer.Tests/OrdinalizeTests.cs
index b84d20fdc..5f8f12ecb 100644
--- a/src/Humanizer.Tests/OrdinalizeTests.cs
+++ b/src/Humanizer.Tests/OrdinalizeTests.cs
@@ -44,6 +44,7 @@ public void OrdinalizeString(string number, string ordinalized)
Assert.Equal(number.Ordinalize(), ordinalized);
}
+ [Theory]
[InlineData(0, "0th")]
[InlineData(1, "1st")]
[InlineData(2, "2nd")]
@@ -72,10 +73,51 @@ public void OrdinalizeString(string number, string ordinalized)
[InlineData(110, "110th")]
[InlineData(1000, "1000th")]
[InlineData(1001, "1001st")]
- [Theory]
- public void OrdanizeNumber(int number, string ordinalized)
+ public void OrdinalizeNumber(int number, string ordinalized)
{
Assert.Equal(number.Ordinalize(), ordinalized);
}
+
+ [Theory]
+ [InlineData(0)]
+ [InlineData(1)]
+ [InlineData(8)]
+ [InlineData(9)]
+ [InlineData(10)]
+ [InlineData(11)]
+ [InlineData(12)]
+ [InlineData(23)]
+ [InlineData(24)]
+ [InlineData(100)]
+ [InlineData(101)]
+ [InlineData(102)]
+ [InlineData(1001)]
+ public void OrdinalizeNumberGenderIndifferent(int number)
+ {
+ string masculineOrdinalized = number.Ordinalize(GrammaticalGender.Masculine);
+ string feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine);
+ Assert.Equal(masculineOrdinalized, feminineOrdinalized);
+ }
+
+ [Theory]
+ [InlineData("0")]
+ [InlineData("1")]
+ [InlineData("8")]
+ [InlineData("9")]
+ [InlineData("10")]
+ [InlineData("11")]
+ [InlineData("12")]
+ [InlineData("23")]
+ [InlineData("24")]
+ [InlineData("100")]
+ [InlineData("101")]
+ [InlineData("102")]
+ [InlineData("1001")]
+ public void OrdinalizeStringGenderIndifferent(string number)
+ {
+ string masculineOrdinalized = number.Ordinalize(GrammaticalGender.Masculine);
+ string feminineOrdinalized = number.Ordinalize(GrammaticalGender.Feminine);
+ Assert.Equal(masculineOrdinalized, feminineOrdinalized);
+ }
}
}
\ No newline at end of file
diff --git a/src/Humanizer/Humanizer.csproj b/src/Humanizer/Humanizer.csproj
index 57d639b34..c7ae8eebf 100644
--- a/src/Humanizer/Humanizer.csproj
+++ b/src/Humanizer/Humanizer.csproj
@@ -88,10 +88,10 @@
-
-
-
-
+
+
+
+
diff --git a/src/Humanizer/Localisation/Ordinalize/BrazilianPortugueseOrdinalizeConverter.cs b/src/Humanizer/Localisation/Ordinalizer/BrazilianPortugueseOrdinalizer.cs
similarity index 79%
rename from src/Humanizer/Localisation/Ordinalize/BrazilianPortugueseOrdinalizeConverter.cs
rename to src/Humanizer/Localisation/Ordinalizer/BrazilianPortugueseOrdinalizer.cs
index f5644bef5..c194bbf37 100644
--- a/src/Humanizer/Localisation/Ordinalize/BrazilianPortugueseOrdinalizeConverter.cs
+++ b/src/Humanizer/Localisation/Ordinalizer/BrazilianPortugueseOrdinalizer.cs
@@ -1,6 +1,6 @@
-namespace Humanizer.Localisation.Ordinalize
+namespace Humanizer.Localisation.Ordinalizer
{
- internal class BrazilianPortugueseOrdinalizeConverter : DefaultOrdinalizeConverter
+ internal class BrazilianPortugueseOrdinalizer : DefaultOrdinalizer
{
public override string Convert(int number, string numberString)
{
diff --git a/src/Humanizer/Localisation/Ordinalize/DefaultOrdinalizeConverter.cs b/src/Humanizer/Localisation/Ordinalizer/DefaultOrdinalizer.cs
similarity index 76%
rename from src/Humanizer/Localisation/Ordinalize/DefaultOrdinalizeConverter.cs
rename to src/Humanizer/Localisation/Ordinalizer/DefaultOrdinalizer.cs
index 50a818416..9d3188311 100644
--- a/src/Humanizer/Localisation/Ordinalize/DefaultOrdinalizeConverter.cs
+++ b/src/Humanizer/Localisation/Ordinalizer/DefaultOrdinalizer.cs
@@ -1,6 +1,6 @@
-namespace Humanizer.Localisation.Ordinalize
+namespace Humanizer.Localisation.Ordinalizer
{
- internal class DefaultOrdinalizeConverter
+ internal class DefaultOrdinalizer
{
public virtual string Convert(int number, string numberString, GrammaticalGender gender)
{
diff --git a/src/Humanizer/Localisation/Ordinalize/EnglishOrdinalizeConverter.cs b/src/Humanizer/Localisation/Ordinalizer/EnglishOrdinalizer.cs
similarity index 79%
rename from src/Humanizer/Localisation/Ordinalize/EnglishOrdinalizeConverter.cs
rename to src/Humanizer/Localisation/Ordinalizer/EnglishOrdinalizer.cs
index 45af3b897..f38c4e728 100644
--- a/src/Humanizer/Localisation/Ordinalize/EnglishOrdinalizeConverter.cs
+++ b/src/Humanizer/Localisation/Ordinalizer/EnglishOrdinalizer.cs
@@ -1,15 +1,13 @@
-namespace Humanizer.Localisation.Ordinalize
+namespace Humanizer.Localisation.Ordinalizer
{
- internal class EnglishOrdinalizeConverter : DefaultOrdinalizeConverter
+ internal class EnglishOrdinalizer : DefaultOrdinalizer
{
public override string Convert(int number, string numberString)
{
int nMod100 = number % 100;
if (nMod100 >= 11 && nMod100 <= 13)
- {
return numberString + "th";
- }
switch (number % 10)
{
diff --git a/src/Humanizer/Localisation/Ordinalize/SpanishOrdinalizeConverter.cs b/src/Humanizer/Localisation/Ordinalizer/SpanishOrdinalizer.cs
similarity index 81%
rename from src/Humanizer/Localisation/Ordinalize/SpanishOrdinalizeConverter.cs
rename to src/Humanizer/Localisation/Ordinalizer/SpanishOrdinalizer.cs
index 367019675..1ebdaea02 100644
--- a/src/Humanizer/Localisation/Ordinalize/SpanishOrdinalizeConverter.cs
+++ b/src/Humanizer/Localisation/Ordinalizer/SpanishOrdinalizer.cs
@@ -1,6 +1,6 @@
-namespace Humanizer.Localisation.Ordinalize
+namespace Humanizer.Localisation.Ordinalizer
{
- internal class SpanishOrdinalizeConverter : DefaultOrdinalizeConverter
+ internal class SpanishOrdinalizer : DefaultOrdinalizer
{
public override string Convert(int number, string numberString)
{
diff --git a/src/Humanizer/OrdinalizeExtensions.cs b/src/Humanizer/OrdinalizeExtensions.cs
index defba31b5..ccfcf6650 100644
--- a/src/Humanizer/OrdinalizeExtensions.cs
+++ b/src/Humanizer/OrdinalizeExtensions.cs
@@ -1,4 +1,4 @@
-using Humanizer.Localisation.Ordinalize;
+using Humanizer.Localisation.Ordinalizer;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -10,12 +10,12 @@ namespace Humanizer
///
public static class OrdinalizeExtensions
{
- private static readonly IDictionary> ConverterFactories =
- new Dictionary>
+ private static readonly IDictionary> OrdinalizerFactories =
+ new Dictionary>
{
- {"en", () => new EnglishOrdinalizeConverter()},
- {"es", () => new SpanishOrdinalizeConverter()},
- {"pt-BR", () => new BrazilianPortugueseOrdinalizeConverter()}
+ {"en", () => new EnglishOrdinalizer()},
+ {"es", () => new SpanishOrdinalizer()},
+ {"pt-BR", () => new BrazilianPortugueseOrdinalizer()}
};
///
@@ -25,7 +25,7 @@ public static class OrdinalizeExtensions
///
public static string Ordinalize(this string numberString)
{
- return Converter.Convert(int.Parse(numberString), numberString);
+ return Ordinalizer.Convert(int.Parse(numberString), numberString);
}
///
@@ -39,7 +39,7 @@ public static string Ordinalize(this string numberString)
///
public static string Ordinalize(this string numberString, GrammaticalGender gender)
{
- return Converter.Convert(int.Parse(numberString), numberString, gender);
+ return Ordinalizer.Convert(int.Parse(numberString), numberString, gender);
}
///
@@ -49,7 +49,7 @@ public static string Ordinalize(this string numberString, GrammaticalGender gend
///
public static string Ordinalize(this int number)
{
- return Converter.Convert(number, number.ToString(CultureInfo.InvariantCulture));
+ return Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture));
}
///
@@ -63,22 +63,22 @@ public static string Ordinalize(this int number)
///
public static string Ordinalize(this int number, GrammaticalGender gender)
{
- return Converter.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender);
+ return Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender);
}
- private static DefaultOrdinalizeConverter Converter
+ private static DefaultOrdinalizer Ordinalizer
{
get
{
- Func converterFactory;
+ Func ordinalizerFactory;
- if (ConverterFactories.TryGetValue(CultureInfo.CurrentUICulture.Name, out converterFactory))
- return converterFactory();
+ if (OrdinalizerFactories.TryGetValue(CultureInfo.CurrentUICulture.Name, out ordinalizerFactory))
+ return ordinalizerFactory();
- if (ConverterFactories.TryGetValue(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, out converterFactory))
- return converterFactory();
+ if (OrdinalizerFactories.TryGetValue(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, out ordinalizerFactory))
+ return ordinalizerFactory();
- return new DefaultOrdinalizeConverter();
+ return new DefaultOrdinalizer();
}
}
}