Skip to content

Commit

Permalink
Removed what remained from DynamicResourceKeys namespace & updated us…
Browse files Browse the repository at this point in the history
…ages & added a missing test case.
  • Loading branch information
wahidshalaly committed Mar 22, 2014
1 parent f4fb576 commit d0f4b8a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.DynamicResourceKeys
namespace Humanizer.Tests
{
public class DateHumanizeWithResourceKeysTests
public class DateHumanizeOneTimeUnitTests
{
static void VerifyWithCurrentDate(string expectedString, TimeSpan deltaFromNow)
{
Expand Down Expand Up @@ -50,12 +50,35 @@ public static IEnumerable<object[]> OneTimeUnitAgoTestsSource
}
}

public static IEnumerable<object[]> OneTimeUnitFromNowTestsSource
{
get
{
return new[] {
new object[]{ TimeUnit.Second, TimeSpan.FromSeconds(1) },
new object[]{ TimeUnit.Minute, TimeSpan.FromMinutes(1) },
new object[]{ TimeUnit.Hour, TimeSpan.FromHours(1) },
new object[]{ TimeUnit.Day, TimeSpan.FromDays(1) },
new object[]{ TimeUnit.Month, TimeSpan.FromDays(30) },
new object[]{ TimeUnit.Year, TimeSpan.FromDays(365) },
};
}
}

[Theory]
[PropertyData("OneTimeUnitAgoTestsSource")]
public void OneTimeUnitAgo(TimeUnit timeUnit, TimeSpan timeSpan)
{
string resourceKey = ResourceKeys.DateHumanize.GetResourceKey(timeUnit, 1);
Verify(Resources.GetResource(resourceKey), timeSpan);
}

[Theory]
[PropertyData("OneTimeUnitFromNowTestsSource")]
public void OneTimeUnitFromNow(TimeUnit timeUnit, TimeSpan timeSpan)
{
string resourceKey = ResourceKeys.DateHumanize.GetResourceKey(timeUnit, 1, true);
Verify(Resources.GetResource(resourceKey), timeSpan);
}
}
}
4 changes: 2 additions & 2 deletions src/Humanizer.Tests/Humanizer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Compile Include="Bytes\ParsingTests.cs" />
<Compile Include="Bytes\ToStringTests.cs" />
<Compile Include="CasingTests.cs" />
<Compile Include="Localisation\DynamicResourceKeys\DateHumanizeTests.cs" />
<Compile Include="DateHumanizeOneTimeUnitTests.cs" />
<Compile Include="Localisation\ar\DateHumanizeTests.cs" />
<Compile Include="Localisation\ar\NumberToWordsTests.cs" />
<Compile Include="Localisation\ar\TimeSpanHumanizeTests.cs" />
Expand All @@ -84,7 +84,7 @@
<Compile Include="Localisation\es\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\pt-BR\DateHumanizeTests.cs" />
<Compile Include="Localisation\pt-BR\TimeSpanHumanizeTests.cs" />
<Compile Include="Localisation\DynamicResourceKeys\ResourceKeyTests.cs" />
<Compile Include="ResourceKeyTests.cs" />
<Compile Include="RomanNumeralTests.cs" />
<Compile Include="RunnableInDebugModeOnlyAttribute.cs" />
<Compile Include="ToQuantityTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Xunit;
using Xunit.Extensions;

namespace Humanizer.Tests.Localisation.DynamicResourceKeys
namespace Humanizer.Tests
{
public class ResourceKeyTests
{
Expand Down Expand Up @@ -40,12 +40,12 @@ public static IEnumerable<object[]> DateHumanizeResourceKeys
get
{
return new[] {
new object[]{ "DateHumanize_SingleSecondAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, 1) },
new object[]{ "DateHumanize_SingleMinuteAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, 1) },
new object[]{ "DateHumanize_SingleHourAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, 1) },
new object[]{ "DateHumanize_SingleDayAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, 1) },
new object[]{ "DateHumanize_SingleMonthAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, 1) },
new object[]{ "DateHumanize_SingleYearAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, 1) },
new object[]{ "DateHumanize_SingleSecondAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second) },
new object[]{ "DateHumanize_SingleMinuteAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute) },
new object[]{ "DateHumanize_SingleHourAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour) },
new object[]{ "DateHumanize_SingleDayAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day) },
new object[]{ "DateHumanize_SingleMonthAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month) },
new object[]{ "DateHumanize_SingleYearAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year) },
new object[]{ "DateHumanize_MultipleSecondsAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Second, 10) },
new object[]{ "DateHumanize_MultipleMinutesAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Minute, 10) },
new object[]{ "DateHumanize_MultipleHoursAgo", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Hour, 10) },
Expand Down Expand Up @@ -73,7 +73,8 @@ public static IEnumerable<object[]> DateHumanizeResourceKeys
new object[]{ "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Day, 0) },
new object[]{ "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Week, 0) },
new object[]{ "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Month, 0) },
new object[]{ "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, 0) }
new object[]{ "DateHumanize_Now", ResourceKeys.DateHumanize.GetResourceKey(TimeUnit.Year, 0) },
new object[]{ "DateHumanize_Now", ResourceKeys.DateHumanize.Now }
};
}
}
Expand All @@ -83,11 +84,11 @@ public static IEnumerable<object[]> TimeSpanHumanizeResourceKeys
get
{
return new[] {
new object[]{ "TimeSpanHumanize_SingleSecond", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 1) },
new object[]{ "TimeSpanHumanize_SingleMinute", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 1) },
new object[]{ "TimeSpanHumanize_SingleHour", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 1) },
new object[]{ "TimeSpanHumanize_SingleDay", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day, 1) },
new object[]{ "TimeSpanHumanize_SingleWeek", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week, 1) },
new object[]{ "TimeSpanHumanize_SingleSecond", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second) },
new object[]{ "TimeSpanHumanize_SingleMinute", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute) },
new object[]{ "TimeSpanHumanize_SingleHour", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour) },
new object[]{ "TimeSpanHumanize_SingleDay", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Day) },
new object[]{ "TimeSpanHumanize_SingleWeek", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Week) },
new object[]{ "TimeSpanHumanize_MultipleSeconds", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Second, 10) },
new object[]{ "TimeSpanHumanize_MultipleMinutes", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Minute, 10) },
new object[]{ "TimeSpanHumanize_MultipleHours", ResourceKeys.TimeSpanHumanize.GetResourceKey(TimeUnit.Hour, 10) },
Expand Down

0 comments on commit d0f4b8a

Please sign in to comment.