-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add culture in humanize method Use Globalization current culture in several extension methods BREAKING CHANGE: Humanize extensions methods * new commit because random test fail in CI * ci: fix download artifacts * fix: fix TUs * fix: fix TUs * fix ci --------- Co-authored-by: Stéphane ANDRE (E104915) <stephane.andre_ext@michelin.com>
- Loading branch information
Showing
38 changed files
with
226 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ tools/FAKE/ | |
build-log.xml | ||
Nuget.key | ||
TestResult.xml | ||
nuget.config | ||
|
||
# Build results | ||
[Bb]uild/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 16 additions & 14 deletions
30
src/MyNet.Humanizer.UnitTests/DateTimeHumanizeExtensionsFrTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,87 @@ | ||
// Copyright (c) Stéphane ANDRE. All Right Reserved. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using MyNet.Utilities.Units; | ||
using MyNet.Humanizer.DateTimes; | ||
using MyNet.Utilities.Units; | ||
using Xunit; | ||
|
||
namespace MyNet.Humanizer.UnitTests | ||
{ | ||
[UseCulture("fr-FR")] | ||
[UseCulture(Culture)] | ||
[Collection("UseCultureSequential")] | ||
public class DateTimeHumanizeExtensionsFrTests | ||
{ | ||
public const string Culture = "fr-FR"; | ||
|
||
[Theory] | ||
[InlineData(1, "il y a 1 seconde")] | ||
[InlineData(2, "il y a 2 secondes")] | ||
[InlineData(10, "il y a 10 secondes")] | ||
public void SecondsAgo(int seconds, string expected) => DateTimeHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Past); | ||
public void SecondsAgo(int seconds, string expected) => DateTimeHumanize.Verify(expected, Culture, seconds, TimeUnit.Second, Tense.Past); | ||
|
||
[Theory] | ||
[InlineData(1, "dans 1 seconde")] | ||
[InlineData(2, "dans 2 secondes")] | ||
[InlineData(10, "dans 10 secondes")] | ||
public void SecondsFromNow(int seconds, string expected) => DateTimeHumanize.Verify(expected, seconds, TimeUnit.Second, Tense.Future); | ||
public void SecondsFromNow(int seconds, string expected) => DateTimeHumanize.Verify(expected, Culture, seconds, TimeUnit.Second, Tense.Future); | ||
|
||
[Theory] | ||
[InlineData(1, "il y a 1 minute")] | ||
[InlineData(2, "il y a 2 minutes")] | ||
[InlineData(10, "il y a 10 minutes")] | ||
[InlineData(60, "il y a 1 heure")] | ||
public void MinutesAgo(int minutes, string expected) => DateTimeHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Past); | ||
public void MinutesAgo(int minutes, string expected) => DateTimeHumanize.Verify(expected, Culture, minutes, TimeUnit.Minute, Tense.Past); | ||
|
||
[Theory] | ||
[InlineData(1, "dans 1 minute")] | ||
[InlineData(2, "dans 2 minutes")] | ||
[InlineData(10, "dans 10 minutes")] | ||
public void MinutesFromNow(int minutes, string expected) => DateTimeHumanize.Verify(expected, minutes, TimeUnit.Minute, Tense.Future); | ||
public void MinutesFromNow(int minutes, string expected) => DateTimeHumanize.Verify(expected, Culture, minutes, TimeUnit.Minute, Tense.Future); | ||
|
||
[Theory] | ||
[InlineData(1, "il y a 1 heure")] | ||
[InlineData(2, "il y a 2 heures")] | ||
[InlineData(10, "il y a 10 heures")] | ||
public void HoursAgo(int hours, string expected) => DateTimeHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Past); | ||
public void HoursAgo(int hours, string expected) => DateTimeHumanize.Verify(expected, Culture, hours, TimeUnit.Hour, Tense.Past); | ||
|
||
[Theory] | ||
[InlineData(1, "dans 1 heure")] | ||
[InlineData(2, "dans 2 heures")] | ||
[InlineData(10, "dans 10 heures")] | ||
public void HoursFromNow(int hours, string expected) => DateTimeHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future); | ||
public void HoursFromNow(int hours, string expected) => DateTimeHumanize.Verify(expected, Culture, hours, TimeUnit.Hour, Tense.Future); | ||
|
||
[Theory] | ||
[InlineData(1, "hier")] | ||
[InlineData(2, "il y a 2 jours")] | ||
[InlineData(10, "il y a 10 jours")] | ||
public void DaysAgo(int days, string expected) => DateTimeHumanize.Verify(expected, days, TimeUnit.Day, Tense.Past); | ||
public void DaysAgo(int days, string expected) => DateTimeHumanize.Verify(expected, Culture, days, TimeUnit.Day, Tense.Past); | ||
|
||
[Theory] | ||
[InlineData(1, "demain")] | ||
[InlineData(2, "dans 2 jours")] | ||
[InlineData(10, "dans 10 jours")] | ||
public void DaysFromNow(int days, string expected) => DateTimeHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future); | ||
public void DaysFromNow(int days, string expected) => DateTimeHumanize.Verify(expected, Culture, days, TimeUnit.Day, Tense.Future); | ||
|
||
[Theory] | ||
[InlineData(1, "il y a 1 mois")] | ||
[InlineData(2, "il y a 2 mois")] | ||
[InlineData(10, "il y a 10 mois")] | ||
public void MonthsAgo(int months, string expected) => DateTimeHumanize.Verify(expected, months, TimeUnit.Month, Tense.Past); | ||
public void MonthsAgo(int months, string expected) => DateTimeHumanize.Verify(expected, Culture, months, TimeUnit.Month, Tense.Past); | ||
|
||
[Theory] | ||
[InlineData(1, "dans 1 mois")] | ||
[InlineData(2, "dans 2 mois")] | ||
[InlineData(10, "dans 10 mois")] | ||
public void MonthsFromNow(int months, string expected) => DateTimeHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future); | ||
public void MonthsFromNow(int months, string expected) => DateTimeHumanize.Verify(expected, Culture, months, TimeUnit.Month, Tense.Future); | ||
|
||
[Theory] | ||
[InlineData(1, "il y a 1 an")] | ||
[InlineData(2, "il y a 2 ans")] | ||
public void YearsAgo(int years, string expected) => DateTimeHumanize.Verify(expected, years, TimeUnit.Year, Tense.Past); | ||
public void YearsAgo(int years, string expected) => DateTimeHumanize.Verify(expected, Culture, years, TimeUnit.Year, Tense.Past); | ||
|
||
[Theory] | ||
[InlineData(1, "dans 1 an")] | ||
[InlineData(2, "dans 2 ans")] | ||
public void YearsFromNow(int years, string expected) => DateTimeHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future); | ||
public void YearsFromNow(int years, string expected) => DateTimeHumanize.Verify(expected, Culture, years, TimeUnit.Year, Tense.Future); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.