-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from msjogren/feature/json-v3-pluralization
Fix #15 Pluralization and fallback languages
- Loading branch information
Showing
5 changed files
with
182 additions
and
64 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
87 changes: 86 additions & 1 deletion
87
tests/I18Next.Net.Tests/Plugins/DefaultPluralResolverFixture.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,6 +1,91 @@ | ||
namespace I18Next.Net.Tests.Plugins | ||
using I18Next.Net.Plugins; | ||
using NUnit.Framework; | ||
|
||
namespace I18Next.Net.Tests.Plugins | ||
{ | ||
[TestFixture] | ||
public class DefaultPluralResolverFixture | ||
{ | ||
[TestCase(JsonFormat.Version1, ExpectedResult = "")] | ||
[TestCase(JsonFormat.Version2, ExpectedResult = "")] | ||
[TestCase(JsonFormat.Version3, ExpectedResult = "")] | ||
public string GetPluralSuffix_OneInEnglish_ShouldReturnEmptyWhenUsingSimpleSuffix(JsonFormat jsonFormatVersion) | ||
{ | ||
var pluralResolver = new DefaultPluralResolver() | ||
{ | ||
JsonFormatVersion = jsonFormatVersion, | ||
UseSimplePluralSuffixIfPossible = true | ||
}; | ||
|
||
return pluralResolver.GetPluralSuffix("en", 1); | ||
} | ||
|
||
[TestCase(JsonFormat.Version1, ExpectedResult = "")] | ||
[TestCase(JsonFormat.Version2, ExpectedResult = "_1")] | ||
[TestCase(JsonFormat.Version3, ExpectedResult = "_0")] | ||
public string GetPluralSuffix_OneInEnglish_ShouldReturnNumberWhenNotUsingSimpleSuffix(JsonFormat jsonFormatVersion) | ||
{ | ||
var pluralResolver = new DefaultPluralResolver() | ||
{ | ||
JsonFormatVersion = jsonFormatVersion, | ||
UseSimplePluralSuffixIfPossible = false | ||
}; | ||
|
||
return pluralResolver.GetPluralSuffix("en", 1); | ||
} | ||
|
||
[TestCase(JsonFormat.Version1, ExpectedResult = "_plural")] | ||
[TestCase(JsonFormat.Version2, ExpectedResult = "_plural")] | ||
[TestCase(JsonFormat.Version3, ExpectedResult = "_plural")] | ||
public string GetPluralSuffix_TwoInEnglish_ShouldReturnPluralWhenUsingSimpleSuffix(JsonFormat jsonFormatVersion) | ||
{ | ||
var pluralResolver = new DefaultPluralResolver() | ||
{ | ||
JsonFormatVersion = jsonFormatVersion, | ||
UseSimplePluralSuffixIfPossible = true | ||
}; | ||
|
||
return pluralResolver.GetPluralSuffix("en", 2); | ||
} | ||
|
||
[TestCase(JsonFormat.Version1, ExpectedResult = "_2")] | ||
[TestCase(JsonFormat.Version2, ExpectedResult = "_2")] | ||
[TestCase(JsonFormat.Version3, ExpectedResult = "_1")] | ||
public string GetPluralSuffix_TwoInEnglish_ShouldReturnNumberWhenNotUsingSimpleSuffix(JsonFormat jsonFormatVersion) | ||
{ | ||
var pluralResolver = new DefaultPluralResolver() | ||
{ | ||
JsonFormatVersion = jsonFormatVersion, | ||
UseSimplePluralSuffixIfPossible = false | ||
}; | ||
|
||
return pluralResolver.GetPluralSuffix("en", 2); | ||
} | ||
|
||
[TestCase(JsonFormat.Version1, ExpectedResult = "")] | ||
[TestCase(JsonFormat.Version2, ExpectedResult = "")] | ||
[TestCase(JsonFormat.Version3, ExpectedResult = "_0")] | ||
public string GetPluralSuffix_OneInJapanese_ShouldReturnNumber(JsonFormat jsonFormatVersion) | ||
{ | ||
var pluralResolver = new DefaultPluralResolver() | ||
{ | ||
JsonFormatVersion = jsonFormatVersion, | ||
}; | ||
|
||
return pluralResolver.GetPluralSuffix("ja", 1); | ||
} | ||
|
||
[TestCase(JsonFormat.Version1, ExpectedResult = "")] | ||
[TestCase(JsonFormat.Version2, ExpectedResult = "")] | ||
[TestCase(JsonFormat.Version3, ExpectedResult = "_0")] | ||
public string GetPluralSuffix_TwoInJapanese_ShouldReturnNumber(JsonFormat jsonFormatVersion) | ||
{ | ||
var pluralResolver = new DefaultPluralResolver() | ||
{ | ||
JsonFormatVersion = jsonFormatVersion, | ||
}; | ||
|
||
return pluralResolver.GetPluralSuffix("ja", 2); | ||
} | ||
} | ||
} |
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