diff --git a/Inflector.Tests/Inflector.Tests.csproj b/Inflector.Tests/Inflector.Tests.csproj
index e6f136a..0f53c2a 100644
--- a/Inflector.Tests/Inflector.Tests.csproj
+++ b/Inflector.Tests/Inflector.Tests.csproj
@@ -34,19 +34,7 @@
..\packages\NUnit.2.5.9.10348\lib\nunit.framework.dll
-
- ..\packages\NUnit.2.5.9.10348\lib\nunit.mocks.dll
-
-
- ..\packages\NUnit.2.5.9.10348\lib\pnunit.framework.dll
-
-
-
-
-
-
-
diff --git a/Inflector.Tests/OrdinalizeTests.cs b/Inflector.Tests/OrdinalizeTests.cs
index 0bd9a40..1dad26d 100644
--- a/Inflector.Tests/OrdinalizeTests.cs
+++ b/Inflector.Tests/OrdinalizeTests.cs
@@ -1,4 +1,7 @@
-using NUnit.Framework;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using NUnit.Framework;
namespace Inflector.Tests
{
@@ -14,6 +17,39 @@ public void Ordinalize()
}
}
+ [TestCase(0, "0th")]
+ [TestCase(1, "1st")]
+ [TestCase(2, "2nd")]
+ [TestCase(3, "3rd")]
+ [TestCase(4, "4th")]
+ [TestCase(5, "5th")]
+ [TestCase(6, "6th")]
+ [TestCase(7, "7th")]
+ [TestCase(8, "8th")]
+ [TestCase(9, "9th")]
+ [TestCase(10, "10th")]
+ [TestCase(11, "11th")]
+ [TestCase(12, "12th")]
+ [TestCase(13, "13th")]
+ [TestCase(14, "14th")]
+ [TestCase(20, "20th")]
+ [TestCase(21, "21st")]
+ [TestCase(22, "22nd")]
+ [TestCase(23, "23rd")]
+ [TestCase(24, "24th")]
+ [TestCase(100, "100th")]
+ [TestCase(101, "101st")]
+ [TestCase(102, "102nd")]
+ [TestCase(103, "103rd")]
+ [TestCase(104, "104th")]
+ [TestCase(110, "110th")]
+ [TestCase(1000, "1000th")]
+ [TestCase(1001, "1001st")]
+ public void OrdanizeNumbersTest(int number, string ordanized)
+ {
+ Assert.AreEqual(number.Ordinalize(), ordanized);
+ }
+
public OrdinalizeTests()
{
TestData.Add("0", "0th");
@@ -44,7 +80,6 @@ public OrdinalizeTests()
TestData.Add("110", "110th");
TestData.Add("1000", "1000th");
TestData.Add("1001", "1001st");
-
}
}
}
\ No newline at end of file
diff --git a/Inflector/Inflector.cs b/Inflector/Inflector.cs
index a0a4fa5..3b871fe 100644
--- a/Inflector/Inflector.cs
+++ b/Inflector/Inflector.cs
@@ -195,29 +195,39 @@ public static string Uncapitalize(this string word)
return word.Substring(0, 1).ToLower() + word.Substring(1);
}
- public static string Ordinalize(this string number)
+ public static string Ordinalize(this string numberString)
{
- int n = int.Parse(number);
- int nMod100 = n % 100;
+ return Ordanize(int.Parse(numberString), numberString);
+ }
+
+ public static string Ordinalize(this int number)
+ {
+ return Ordanize(number, number.ToString());
+ }
+
+ private static string Ordanize(int number, string numberString)
+ {
+ int nMod100 = number % 100;
if (nMod100 >= 11 && nMod100 <= 13)
{
- return number + "th";
+ return numberString + "th";
}
- switch (n % 10)
+ switch (number % 10)
{
case 1:
- return number + "st";
+ return numberString + "st";
case 2:
- return number + "nd";
+ return numberString + "nd";
case 3:
- return number + "rd";
+ return numberString + "rd";
default:
- return number + "th";
+ return numberString + "th";
}
}
+
public static string Dasherize(this string underscoredWord)
{
return underscoredWord.Replace('_', '-');
diff --git a/Inflector/Inflector.csproj b/Inflector/Inflector.csproj
index cda6e68..ebab15b 100644
--- a/Inflector/Inflector.csproj
+++ b/Inflector/Inflector.csproj
@@ -10,8 +10,9 @@
Properties
Inflector
Inflector
- v4.0
+ v3.5
512
+
true
@@ -33,11 +34,6 @@
-
-
-
-
-