-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d20abc
commit dfe6226
Showing
385 changed files
with
25,785 additions
and
26,175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
namespace Humanizer.Tests | ||
namespace Humanizer.Tests; | ||
|
||
public class ArticlePrefixSortTests | ||
{ | ||
public class ArticlePrefixSortTests | ||
{ | ||
[Theory] | ||
[InlineData(new[] { "Ant", "The Theater", "The apple", "Fox", "Bear" }, new[] { "Ant", "The apple", "Bear", "Fox", "The Theater" })] | ||
[InlineData(new[] { "An Ant", "The Theater", "the apple", "a Fox", "Bear" }, new[] { "An Ant", "the apple", "Bear", "a Fox", "The Theater" })] | ||
[InlineData(new[] { "Ant", "A Theater", "an apple", "Fox", "Bear" }, new[] { "Ant", "an apple", "Bear", "Fox", "A Theater" })] | ||
[InlineData(new[] { " Ant ", " A Theater ", " an apple ", " Fox", "Bear " }, new[] { "A Theater", "an apple", "Ant", "Bear", "Fox" })] | ||
[InlineData(new[] { "The General Theory of Relativity" }, new[] { "The General Theory of Relativity" })] | ||
public void SortStringArrayIgnoringArticlePrefixes(string[] input, string[] expectedOutput) => | ||
Assert.Equal(expectedOutput, EnglishArticle.PrependArticleSuffix(EnglishArticle.AppendArticlePrefix(input))); | ||
[Theory] | ||
[InlineData(new[] { "Ant", "The Theater", "The apple", "Fox", "Bear" }, new[] { "Ant", "The apple", "Bear", "Fox", "The Theater" })] | ||
[InlineData(new[] { "An Ant", "The Theater", "the apple", "a Fox", "Bear" }, new[] { "An Ant", "the apple", "Bear", "a Fox", "The Theater" })] | ||
[InlineData(new[] { "Ant", "A Theater", "an apple", "Fox", "Bear" }, new[] { "Ant", "an apple", "Bear", "Fox", "A Theater" })] | ||
[InlineData(new[] { " Ant ", " A Theater ", " an apple ", " Fox", "Bear " }, new[] { "A Theater", "an apple", "Ant", "Bear", "Fox" })] | ||
[InlineData(new[] { "The General Theory of Relativity" }, new[] { "The General Theory of Relativity" })] | ||
public void SortStringArrayIgnoringArticlePrefixes(string[] input, string[] expectedOutput) => | ||
Assert.Equal(expectedOutput, EnglishArticle.PrependArticleSuffix(EnglishArticle.AppendArticlePrefix(input))); | ||
|
||
[Fact] | ||
public void An_Empty_String_Array_Throws_ArgumentOutOfRangeException() | ||
{ | ||
[Fact] | ||
public void An_Empty_String_Array_Throws_ArgumentOutOfRangeException() | ||
{ | ||
string[] items = []; | ||
void action() => EnglishArticle.AppendArticlePrefix(items); | ||
Assert.Throws<ArgumentOutOfRangeException>(action); | ||
} | ||
} | ||
} | ||
} |
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,40 +1,39 @@ | ||
namespace Humanizer.Tests | ||
{ | ||
[UseCulture("en")] | ||
public class BitFieldEnumHumanizeTests | ||
{ | ||
[Fact] | ||
public void CanHumanizeSingleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, BitFieldEnumUnderTest.RED.Humanize()); | ||
namespace Humanizer.Tests; | ||
|
||
[Fact] | ||
public void CanHumanizeMultipleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, BitFieldEnumUnderTest.DARK_GRAY.Humanize()); | ||
[UseCulture("en")] | ||
public class BitFieldEnumHumanizeTests | ||
{ | ||
[Fact] | ||
public void CanHumanizeSingleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, BitFieldEnumUnderTest.RED.Humanize()); | ||
|
||
[Fact] | ||
public void CanHumanizeMultipleValueBitFieldEnum() | ||
{ | ||
var xoredBitFlag = BitFieldEnumUnderTest.RED | BitFieldEnumUnderTest.DARK_GRAY; | ||
Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); | ||
} | ||
[Fact] | ||
public void CanHumanizeMultipleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, BitFieldEnumUnderTest.DARK_GRAY.Humanize()); | ||
|
||
[Fact] | ||
public void CanHumanizeShortSingleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, ShortBitFieldEnumUnderTest.RED.Humanize()); | ||
[Fact] | ||
public void CanHumanizeMultipleValueBitFieldEnum() | ||
{ | ||
var xoredBitFlag = BitFieldEnumUnderTest.RED | BitFieldEnumUnderTest.DARK_GRAY; | ||
Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); | ||
} | ||
|
||
[Fact] | ||
public void CanHumanizeShortMultipleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, ShortBitFieldEnumUnderTest.DARK_GRAY.Humanize()); | ||
[Fact] | ||
public void CanHumanizeShortSingleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute, ShortBitFieldEnumUnderTest.RED.Humanize()); | ||
|
||
[Fact] | ||
public void CanHumanizeShortMultipleValueBitFieldEnum() | ||
{ | ||
var xoredBitFlag = ShortBitFieldEnumUnderTest.RED | ShortBitFieldEnumUnderTest.DARK_GRAY; | ||
Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); | ||
} | ||
[Fact] | ||
public void CanHumanizeShortMultipleWordDescriptionAttribute() => | ||
Assert.Equal(BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute, ShortBitFieldEnumUnderTest.DARK_GRAY.Humanize()); | ||
|
||
[Fact] | ||
public void CanHumanizeBitFieldEnumWithZeroValue() => | ||
Assert.Equal(BitFlagEnumTestsResources.None, BitFieldEnumUnderTest.NONE.Humanize()); | ||
[Fact] | ||
public void CanHumanizeShortMultipleValueBitFieldEnum() | ||
{ | ||
var xoredBitFlag = ShortBitFieldEnumUnderTest.RED | ShortBitFieldEnumUnderTest.DARK_GRAY; | ||
Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize()); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void CanHumanizeBitFieldEnumWithZeroValue() => | ||
Assert.Equal(BitFlagEnumTestsResources.None, BitFieldEnumUnderTest.NONE.Humanize()); | ||
} |
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,33 +1,32 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Humanizer.Tests | ||
namespace Humanizer.Tests; | ||
|
||
[Flags] | ||
public enum BitFieldEnumUnderTest : int | ||
{ | ||
[Flags] | ||
public enum BitFieldEnumUnderTest : int | ||
{ | ||
[Display(Description = BitFlagEnumTestsResources.None)] | ||
NONE = 0, | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] | ||
RED = 1, | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] | ||
DARK_GRAY = 2 | ||
} | ||
[Display(Description = BitFlagEnumTestsResources.None)] | ||
NONE = 0, | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] | ||
RED = 1, | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] | ||
DARK_GRAY = 2 | ||
} | ||
|
||
[Flags] | ||
public enum ShortBitFieldEnumUnderTest : short | ||
{ | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] | ||
RED = 1, | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] | ||
DARK_GRAY = 2 | ||
} | ||
[Flags] | ||
public enum ShortBitFieldEnumUnderTest : short | ||
{ | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)] | ||
RED = 1, | ||
[Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)] | ||
DARK_GRAY = 2 | ||
} | ||
|
||
public class BitFlagEnumTestsResources | ||
{ | ||
public const string None = "None"; | ||
public const string MemberWithSingleWordDisplayAttribute = "Red"; | ||
public const string MemberWithMultipleWordDisplayAttribute = "Dark Gray"; | ||
public class BitFlagEnumTestsResources | ||
{ | ||
public const string None = "None"; | ||
public const string MemberWithSingleWordDisplayAttribute = "Red"; | ||
public const string MemberWithMultipleWordDisplayAttribute = "Dark Gray"; | ||
|
||
public const string ExpectedResultWhenBothValuesXored = "Red and Dark Gray"; | ||
} | ||
} | ||
public const string ExpectedResultWhenBothValuesXored = "Red and Dark Gray"; | ||
} |
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.