diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..180b856 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: nuget + directory: "/" + schedule: + interval: daily + time: "00:00" + open-pull-requests-limit: 10 diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 4f31b87..b64fe39 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -21,10 +21,10 @@ jobs: with: fetch-depth: 0 - - name: Install .NET 5 + - name: Install .NET 6 uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: NuGet restore run: dotnet restore diff --git a/.gitignore b/.gitignore index 702b0ea..53c974c 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ bld/ # Visual Studio 2015/2017 cache/options directory .vs/ +.idea/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ diff --git a/src/Extensions/CharExtensions.cs b/src/Extensions/CharExtensions.cs index 5da2d26..9fff5fc 100644 --- a/src/Extensions/CharExtensions.cs +++ b/src/Extensions/CharExtensions.cs @@ -1,38 +1,35 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using static MyNihongo.KanaDetector.Resources.Constants; +namespace MyNihongo.KanaDetector; -namespace MyNihongo.KanaDetector.Extensions +public static class CharExtensions { - public static class CharExtensions - { - public static bool IsHiragana(this char @this) => - @this is >= Kana.HiraganaStart and <= Kana.HiraganaEnd; + public static bool IsHiragana(this char @this) => + @this is >= Kana.HiraganaStart and <= Kana.HiraganaEnd; - public static bool IsKatakana(this char @this) => - @this is >= Kana.KatakanaStart and <= Kana.KatakanaEnd; + public static bool IsKatakana(this char @this) => + @this is >= Kana.KatakanaStart and <= Kana.KatakanaEnd; - public static bool IsKana(this char @this) => - @this.IsHiragana() || @this.IsKatakana(); + public static bool IsKana(this char @this) => + @this.IsHiragana() || @this.IsKatakana(); - public static bool IsKanji(this char @this) => - @this is - >= Kanji.Start and <= Kanji.End or - >= Kanji.RareStart and <= Kanji.RareEnd or - Kanji.IterationMark; + public static bool IsKanji(this char @this) => + @this is + >= Kanji.Start and <= Kanji.End or + >= Kanji.RareStart and <= Kanji.RareEnd or + Kanji.IterationMark; - public static bool IsKanaOrKanji(this char @this) => - @this.IsHiragana() || @this.IsKatakana() || @this.IsKanji(); + public static bool IsKanaOrKanji(this char @this) => + @this.IsHiragana() || @this.IsKatakana() || @this.IsKanji(); - public static bool IsRomaji(this char @this) => - @this - is >= Romaji.EnglishStart and <= Romaji.EnglishEnd or - Romaji.Hepbun.CapitalA or Romaji.Hepbun.SmallA or - Romaji.Hepbun.CapitalI or Romaji.Hepbun.SmallI or - Romaji.Hepbun.CapitalU or Romaji.Hepbun.SmallU or - Romaji.Hepbun.CapitalE or Romaji.Hepbun.SmallE or - Romaji.Hepbun.CapitalO or Romaji.Hepbun.SmallO; - } + public static bool IsRomaji(this char @this) => + @this + is >= Romaji.EnglishStart and <= Romaji.EnglishEnd or + Romaji.Hepbun.CapitalA or Romaji.Hepbun.SmallA or + Romaji.Hepbun.CapitalI or Romaji.Hepbun.SmallI or + Romaji.Hepbun.CapitalU or Romaji.Hepbun.SmallU or + Romaji.Hepbun.CapitalE or Romaji.Hepbun.SmallE or + Romaji.Hepbun.CapitalO or Romaji.Hepbun.SmallO; } diff --git a/src/Extensions/StringExtensions.cs b/src/Extensions/StringExtensions.cs index a48e0a8..8a2a8e5 100644 --- a/src/Extensions/StringExtensions.cs +++ b/src/Extensions/StringExtensions.cs @@ -1,161 +1,160 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -namespace MyNihongo.KanaDetector.Extensions +namespace MyNihongo.KanaDetector; + +public static class StringExtensions { - public static class StringExtensions + #region Is methods + + public static bool IsHiragana(this string @this, bool whenEmpty = false) { - #region Is methods + if (string.IsNullOrEmpty(@this)) + return whenEmpty; - public static bool IsHiragana(this string @this) - { - if (string.IsNullOrEmpty(@this)) + for (var i = 0; i < @this.Length; i++) + if (!@this[i].IsHiragana()) return false; - for (var i = 0; i < @this.Length; i++) - if (!@this[i].IsHiragana()) - return false; + return true; + } - return true; - } + public static bool IsKatakana(this string @this, bool whenEmpty = false) + { + if (string.IsNullOrEmpty(@this)) + return whenEmpty; - public static bool IsKatakana(this string @this) - { - if (string.IsNullOrEmpty(@this)) + for (var i = 0; i < @this.Length; i++) + if (!@this[i].IsKatakana()) return false; - for (var i = 0; i < @this.Length; i++) - if (!@this[i].IsKatakana()) - return false; + return true; + } - return true; - } + public static bool IsKana(this string @this, bool whenEmpty = false) + { + if (string.IsNullOrEmpty(@this)) + return whenEmpty; - public static bool IsKana(this string @this) - { - if (string.IsNullOrEmpty(@this)) + for (var i = 0; i < @this.Length; i++) + if (!@this[i].IsKana()) return false; - for (var i = 0; i < @this.Length; i++) - if (!@this[i].IsKana()) - return false; + return true; + } - return true; - } + public static bool IsKanji(this string @this, bool whenEmpty = false) + { + if (string.IsNullOrEmpty(@this)) + return whenEmpty; - public static bool IsKanji(this string @this) - { - if (string.IsNullOrEmpty(@this)) + for (var i = 0; i < @this.Length; i++) + if (!@this[i].IsKanji()) return false; - for (var i = 0; i < @this.Length; i++) - if (!@this[i].IsKanji()) - return false; + return true; + } - return true; - } + public static bool IsKanaOrKanji(this string @this, bool whenEmpty = false) + { + if (string.IsNullOrEmpty(@this)) + return whenEmpty; - public static bool IsKanaOrKanji(this string @this) - { - if (string.IsNullOrEmpty(@this)) + for (var i = 0; i < @this.Length; i++) + if (!@this[i].IsKanaOrKanji()) return false; - for (var i = 0; i < @this.Length; i++) - if (!@this[i].IsKanaOrKanji()) - return false; + return true; + } - return true; - } + public static bool IsRomaji(this string @this, bool whenEmpty = false) + { + if (string.IsNullOrEmpty(@this)) + return whenEmpty; - public static bool IsRomaji(this string @this) - { - if (string.IsNullOrEmpty(@this)) + for (var i = 0; i < @this.Length; i++) + if (!@this[i].IsRomaji()) return false; - for (var i = 0; i < @this.Length; i++) - if (!@this[i].IsRomaji()) - return false; - - return true; - } - - #endregion - - #region Has methods + return true; + } - public static bool HasHiragana(this string @this) - { - if (string.IsNullOrEmpty(@this)) - return false; + #endregion - for (var i = 0; i < @this.Length; i++) - if (@this[i].IsHiragana()) - return true; + #region Has methods + public static bool HasHiragana(this string @this) + { + if (string.IsNullOrEmpty(@this)) return false; - } - public static bool HasKatakana(this string @this) - { - if (string.IsNullOrEmpty(@this)) - return false; + for (var i = 0; i < @this.Length; i++) + if (@this[i].IsHiragana()) + return true; - for (var i = 0; i < @this.Length; i++) - if (@this[i].IsKatakana()) - return true; + return false; + } + public static bool HasKatakana(this string @this) + { + if (string.IsNullOrEmpty(@this)) return false; - } - public static bool HasKana(this string @this) - { - if (string.IsNullOrEmpty(@this)) - return false; + for (var i = 0; i < @this.Length; i++) + if (@this[i].IsKatakana()) + return true; - for (var i = 0; i < @this.Length; i++) - if (@this[i].IsKana()) - return true; + return false; + } + public static bool HasKana(this string @this) + { + if (string.IsNullOrEmpty(@this)) return false; - } - public static bool HasKanji(this string @this) - { - if (string.IsNullOrEmpty(@this)) - return false; + for (var i = 0; i < @this.Length; i++) + if (@this[i].IsKana()) + return true; - for (var i = 0; i < @this.Length; i++) - if (@this[i].IsKanji()) - return true; + return false; + } + public static bool HasKanji(this string @this) + { + if (string.IsNullOrEmpty(@this)) return false; - } - public static bool HasKanaOrKanji(this string @this) - { - if (string.IsNullOrEmpty(@this)) - return false; + for (var i = 0; i < @this.Length; i++) + if (@this[i].IsKanji()) + return true; - for (var i = 0; i < @this.Length; i++) - if (@this[i].IsKanaOrKanji()) - return true; + return false; + } + public static bool HasKanaOrKanji(this string @this) + { + if (string.IsNullOrEmpty(@this)) return false; - } - public static bool HasRomaji(this string @this) - { - if (string.IsNullOrEmpty(@this)) - return false; + for (var i = 0; i < @this.Length; i++) + if (@this[i].IsKanaOrKanji()) + return true; - for (var i = 0; i < @this.Length; i++) - if (@this[i].IsRomaji()) - return true; + return false; + } + public static bool HasRomaji(this string @this) + { + if (string.IsNullOrEmpty(@this)) return false; - } - #endregion + for (var i = 0; i < @this.Length; i++) + if (@this[i].IsRomaji()) + return true; + + return false; } + + #endregion } diff --git a/src/MyNihongo.KanaDetector.csproj b/src/MyNihongo.KanaDetector.csproj index 03c5832..4c898e1 100644 --- a/src/MyNihongo.KanaDetector.csproj +++ b/src/MyNihongo.KanaDetector.csproj @@ -1,15 +1,16 @@ - net5.0 + netstandard2.0 + latest enable MyNihongo.KanaDetector MyNihongo MyNihongo Detect kana, kanji and romaji in characters and strings - Copyright © 2021 MyNihongo + Copyright © 2023 MyNihongo MIT - 1.0.1 + 1.0.2 https://github.com/MyNihongo/KanaDetector https://github.com/MyNihongo/KanaDetector https://github.com/MyNihongo/KanaDetector/releases/ @@ -25,4 +26,8 @@ + + + + diff --git a/src/MyNihongo.KanaDetector.csproj.DotSettings b/src/MyNihongo.KanaDetector.csproj.DotSettings new file mode 100644 index 0000000..b5b4743 --- /dev/null +++ b/src/MyNihongo.KanaDetector.csproj.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/src/Resources/Constants.cs b/src/Resources/Constants.cs index ff03c74..2ff2c81 100644 --- a/src/Resources/Constants.cs +++ b/src/Resources/Constants.cs @@ -1,47 +1,45 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MyNihongo.KanaDetector.Tests")] -namespace MyNihongo.KanaDetector.Resources +namespace MyNihongo.KanaDetector; + +internal static class Constants { - internal static class Constants + internal static class Romaji { - internal static class Romaji - { - internal const char EnglishStart = '!'; - internal const char EnglishEnd = '~'; - - internal static class Hepbun - { - internal const char CapitalA = 'Ā'; - internal const char SmallA = 'ā'; - internal const char CapitalI = 'Ī'; - internal const char SmallI = 'ī'; - internal const char CapitalU = 'Ū'; - internal const char SmallU = 'ū'; - internal const char CapitalE = 'Ē'; - internal const char SmallE = 'ē'; - internal const char CapitalO = 'Ō'; - internal const char SmallO = 'ō'; - } - } + internal const char EnglishStart = '!'; + internal const char EnglishEnd = '~'; - internal static class Kana + internal static class Hepbun { - internal const char HiraganaStart = 'ぁ'; - internal const char HiraganaEnd = 'ゖ'; - internal const char KatakanaStart = 'ァ'; - internal const char KatakanaEnd = 'ー'; + internal const char CapitalA = 'Ā'; + internal const char SmallA = 'ā'; + internal const char CapitalI = 'Ī'; + internal const char SmallI = 'ī'; + internal const char CapitalU = 'Ū'; + internal const char SmallU = 'ū'; + internal const char CapitalE = 'Ē'; + internal const char SmallE = 'ē'; + internal const char CapitalO = 'Ō'; + internal const char SmallO = 'ō'; } + } - internal static class Kanji - { - internal const char Start = '一'; - internal const char End = '龯'; - internal const char RareStart = '㐀'; - internal const char RareEnd = '䶵'; - internal const char IterationMark = '々'; - } + internal static class Kana + { + internal const char HiraganaStart = 'ぁ'; + internal const char HiraganaEnd = 'ゖ'; + internal const char KatakanaStart = 'ァ'; + internal const char KatakanaEnd = 'ー'; + } + + internal static class Kanji + { + internal const char Start = '一'; + internal const char End = '龯'; + internal const char RareStart = '㐀'; + internal const char RareEnd = '䶵'; + internal const char IterationMark = '々'; } } diff --git a/src/_Usings.cs b/src/_Usings.cs new file mode 100644 index 0000000..fc1dfa4 --- /dev/null +++ b/src/_Usings.cs @@ -0,0 +1,4 @@ +global using static MyNihongo.KanaDetector.Constants; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("MyNihongo.KanaDetector.Tests")] diff --git a/tests/Extensions/CharExtensionsTests/IsHiraganaShould.cs b/tests/Extensions/CharExtensionsTests/IsHiraganaShould.cs index 65404ab..be3ca47 100644 --- a/tests/Extensions/CharExtensionsTests/IsHiraganaShould.cs +++ b/tests/Extensions/CharExtensionsTests/IsHiraganaShould.cs @@ -1,66 +1,60 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests +public class IsHiraganaShould { - public class IsHiraganaShould + [Fact] + public void BeTrueForAllHiraganaChars() { - [Fact] - public void BeTrueForAllHiraganaChars() + foreach (var @char in CharacterHelper.Hiragana) { - foreach (var @char in CharacterHelper.Hiragana) - { - var result = @char.IsHiragana(); + var result = @char.IsHiragana(); - result - .Should() - .BeTrue("{0} is hiragana", @char); - } + result + .Should() + .BeTrue("{0} is hiragana", @char); } + } - [Fact] - public void BeFalseForAllKatakanaChars() + [Fact] + public void BeFalseForAllKatakanaChars() + { + foreach (var @char in CharacterHelper.Katakana) { - foreach (var @char in CharacterHelper.Katakana) - { - var result = @char.IsHiragana(); + var result = @char.IsHiragana(); - result - .Should() - .BeFalse("{0} is katakana", @char); - } + result + .Should() + .BeFalse("{0} is katakana", @char); } + } - [Fact] - public void BeFalseForKanji() + [Fact] + public void BeFalseForKanji() + { + foreach (var @char in CharacterHelper.Kanji()) { - foreach (var @char in CharacterHelper.Kanji()) - { - var result = @char.IsHiragana(); + var result = @char.IsHiragana(); - result - .Should() - .BeFalse("{0} is kanji", @char); - } + result + .Should() + .BeFalse("{0} is kanji", @char); } + } - [Fact] - public void BeFalseForRomaji() + [Fact] + public void BeFalseForRomaji() + { + foreach (var @char in CharacterHelper.Romaji) { - foreach (var @char in CharacterHelper.Romaji) - { - var result = @char.IsHiragana(); + var result = @char.IsHiragana(); - result - .Should() - .BeFalse("{0} is romaji"); - } + result + .Should() + .BeFalse("{0} is romaji"); } } } diff --git a/tests/Extensions/CharExtensionsTests/IsKanaOrKanjiShould.cs b/tests/Extensions/CharExtensionsTests/IsKanaOrKanjiShould.cs index 3c48554..984fd82 100644 --- a/tests/Extensions/CharExtensionsTests/IsKanaOrKanjiShould.cs +++ b/tests/Extensions/CharExtensionsTests/IsKanaOrKanjiShould.cs @@ -1,66 +1,60 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests +public class IsKanaOrKanjiShould { - public class IsKanaOrKanjiShould + [Fact] + public void BeTrueForAllHiraganaChars() { - [Fact] - public void BeTrueForAllHiraganaChars() + foreach (var @char in CharacterHelper.Hiragana) { - foreach (var @char in CharacterHelper.Hiragana) - { - var result = @char.IsKanaOrKanji(); + var result = @char.IsKanaOrKanji(); - result - .Should() - .BeTrue("{0} is hiragana", @char); - } + result + .Should() + .BeTrue("{0} is hiragana", @char); } + } - [Fact] - public void BeTrueForAllKatakanaChars() + [Fact] + public void BeTrueForAllKatakanaChars() + { + foreach (var @char in CharacterHelper.Katakana) { - foreach (var @char in CharacterHelper.Katakana) - { - var result = @char.IsKanaOrKanji(); + var result = @char.IsKanaOrKanji(); - result - .Should() - .BeTrue("{0} is katakana", @char); - } + result + .Should() + .BeTrue("{0} is katakana", @char); } + } - [Fact] - public void BeTrueForKanji() + [Fact] + public void BeTrueForKanji() + { + foreach (var @char in CharacterHelper.Kanji()) { - foreach (var @char in CharacterHelper.Kanji()) - { - var result = @char.IsKanaOrKanji(); + var result = @char.IsKanaOrKanji(); - result - .Should() - .BeTrue("{0} is kanji", @char); - } + result + .Should() + .BeTrue("{0} is kanji", @char); } + } - [Fact] - public void BeFalseForRomaji() + [Fact] + public void BeFalseForRomaji() + { + foreach (var @char in CharacterHelper.Romaji) { - foreach (var @char in CharacterHelper.Romaji) - { - var result = @char.IsKanaOrKanji(); + var result = @char.IsKanaOrKanji(); - result - .Should() - .BeFalse("{0} is romaji", @char); - } + result + .Should() + .BeFalse("{0} is romaji", @char); } } -} +} \ No newline at end of file diff --git a/tests/Extensions/CharExtensionsTests/IsKanaShould.cs b/tests/Extensions/CharExtensionsTests/IsKanaShould.cs index 313e459..8fd3508 100644 --- a/tests/Extensions/CharExtensionsTests/IsKanaShould.cs +++ b/tests/Extensions/CharExtensionsTests/IsKanaShould.cs @@ -1,66 +1,60 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests +public class IsKanaShould { - public class IsKanaShould + [Fact] + public void BeTrueForAllHiraganaChars() { - [Fact] - public void BeTrueForAllHiraganaChars() + foreach (var @char in CharacterHelper.Hiragana) { - foreach (var @char in CharacterHelper.Hiragana) - { - var result = @char.IsKana(); + var result = @char.IsKana(); - result - .Should() - .BeTrue("{0} is hiragana", @char); - } + result + .Should() + .BeTrue("{0} is hiragana", @char); } + } - [Fact] - public void BeTrueForAllKatakanaChars() + [Fact] + public void BeTrueForAllKatakanaChars() + { + foreach (var @char in CharacterHelper.Katakana) { - foreach (var @char in CharacterHelper.Katakana) - { - var result = @char.IsKana(); + var result = @char.IsKana(); - result - .Should() - .BeTrue("{0} is katakana", @char); - } + result + .Should() + .BeTrue("{0} is katakana", @char); } + } - [Fact] - public void BeFalseForAllKanjiChars() + [Fact] + public void BeFalseForAllKanjiChars() + { + foreach (var @char in CharacterHelper.Kanji()) { - foreach (var @char in CharacterHelper.Kanji()) - { - var result = @char.IsKana(); + var result = @char.IsKana(); - result - .Should() - .BeFalse("{0} is kanji", @char); - } + result + .Should() + .BeFalse("{0} is kanji", @char); } + } - [Fact] - public void BeFalseForAllRomajiChars() + [Fact] + public void BeFalseForAllRomajiChars() + { + foreach (var @char in CharacterHelper.Romaji) { - foreach (var @char in CharacterHelper.Romaji) - { - var result = @char.IsKana(); + var result = @char.IsKana(); - result - .Should() - .BeFalse("{0} is romaji", @char); - } + result + .Should() + .BeFalse("{0} is romaji", @char); } } -} +} \ No newline at end of file diff --git a/tests/Extensions/CharExtensionsTests/IsKanjiShould.cs b/tests/Extensions/CharExtensionsTests/IsKanjiShould.cs index f6286ad..72f36fd 100644 --- a/tests/Extensions/CharExtensionsTests/IsKanjiShould.cs +++ b/tests/Extensions/CharExtensionsTests/IsKanjiShould.cs @@ -1,66 +1,60 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests +public class IsKanjiShould { - public class IsKanjiShould + [Fact] + public void BeTrueForKanji() { - [Fact] - public void BeTrueForKanji() + foreach (var @char in CharacterHelper.Kanji()) { - foreach (var @char in CharacterHelper.Kanji()) - { - var result = @char.IsKanji(); + var result = @char.IsKanji(); - result - .Should() - .BeTrue("{0} is kanji", @char); - } + result + .Should() + .BeTrue("{0} is kanji", @char); } + } - [Fact] - public void BeFalseForAllHiraganaChars() + [Fact] + public void BeFalseForAllHiraganaChars() + { + foreach (var @char in CharacterHelper.Hiragana) { - foreach (var @char in CharacterHelper.Hiragana) - { - var result = @char.IsKanji(); + var result = @char.IsKanji(); - result - .Should() - .BeFalse("{0} is hiragana", @char); - } + result + .Should() + .BeFalse("{0} is hiragana", @char); } + } - [Fact] - public void BeFalseForAllKatakanaChars() + [Fact] + public void BeFalseForAllKatakanaChars() + { + foreach (var @char in CharacterHelper.Katakana) { - foreach (var @char in CharacterHelper.Katakana) - { - var result = @char.IsKanji(); + var result = @char.IsKanji(); - result - .Should() - .BeFalse("{0} is katakana", @char); - } + result + .Should() + .BeFalse("{0} is katakana", @char); } + } - [Fact] - public void BeFalseForAllRomajiChars() + [Fact] + public void BeFalseForAllRomajiChars() + { + foreach (var @char in CharacterHelper.Romaji) { - foreach (var @char in CharacterHelper.Romaji) - { - var result = @char.IsKanji(); + var result = @char.IsKanji(); - result - .Should() - .BeFalse("{0} is romaji", @char); - } + result + .Should() + .BeFalse("{0} is romaji", @char); } } -} +} \ No newline at end of file diff --git a/tests/Extensions/CharExtensionsTests/IsKatakanaShould.cs b/tests/Extensions/CharExtensionsTests/IsKatakanaShould.cs index 521c215..525fdd1 100644 --- a/tests/Extensions/CharExtensionsTests/IsKatakanaShould.cs +++ b/tests/Extensions/CharExtensionsTests/IsKatakanaShould.cs @@ -1,66 +1,60 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests +public class IsKatakanaShould { - public class IsKatakanaShould + [Fact] + public void BeTrueForAllKatakanaChars() { - [Fact] - public void BeTrueForAllKatakanaChars() + foreach (var @char in CharacterHelper.Katakana) { - foreach (var @char in CharacterHelper.Katakana) - { - var result = @char.IsKatakana(); + var result = @char.IsKatakana(); - result - .Should() - .BeTrue("{0} is katakana", @char); - } + result + .Should() + .BeTrue("{0} is katakana", @char); } + } - [Fact] - public void BeFalseForAllHiraganaChars() + [Fact] + public void BeFalseForAllHiraganaChars() + { + foreach (var @char in CharacterHelper.Hiragana) { - foreach (var @char in CharacterHelper.Hiragana) - { - var result = @char.IsKatakana(); + var result = @char.IsKatakana(); - result - .Should() - .BeFalse("{0} is hiragana", @char); - } + result + .Should() + .BeFalse("{0} is hiragana", @char); } + } - [Fact] - public void BeFalseForKanji() + [Fact] + public void BeFalseForKanji() + { + foreach (var @char in CharacterHelper.Kanji()) { - foreach (var @char in CharacterHelper.Kanji()) - { - var result = @char.IsKatakana(); + var result = @char.IsKatakana(); - result - .Should() - .BeFalse("{0} is kanji", @char); - } + result + .Should() + .BeFalse("{0} is kanji", @char); } + } - [Fact] - public void BeFalseForRomaji() + [Fact] + public void BeFalseForRomaji() + { + foreach (var @char in CharacterHelper.Romaji) { - foreach (var @char in CharacterHelper.Romaji) - { - var result = @char.IsKatakana(); + var result = @char.IsKatakana(); - result - .Should() - .BeFalse("{0} is romaji", @char); - } + result + .Should() + .BeFalse("{0} is romaji", @char); } } -} +} \ No newline at end of file diff --git a/tests/Extensions/CharExtensionsTests/IsRomajiShould.cs b/tests/Extensions/CharExtensionsTests/IsRomajiShould.cs index 022050c..6ac2444 100644 --- a/tests/Extensions/CharExtensionsTests/IsRomajiShould.cs +++ b/tests/Extensions/CharExtensionsTests/IsRomajiShould.cs @@ -1,66 +1,60 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.CharExtensionsTests +public sealed class IsRomajiShould { - public sealed class IsRomajiShould + [Fact] + public void BeTrueForAllRomajiChars() { - [Fact] - public void BeTrueForAllRomajiChars() + foreach (var @char in CharacterHelper.Romaji) { - foreach (var @char in CharacterHelper.Romaji) - { - var result = @char.IsRomaji(); + var result = @char.IsRomaji(); - result - .Should() - .BeTrue("{0} is romaji", @char); - } + result + .Should() + .BeTrue("{0} is romaji", @char); } + } - [Fact] - public void BeFalseForAllHiraganaChars() + [Fact] + public void BeFalseForAllHiraganaChars() + { + foreach (var @char in CharacterHelper.Hiragana) { - foreach (var @char in CharacterHelper.Hiragana) - { - var result = @char.IsRomaji(); + var result = @char.IsRomaji(); - result - .Should() - .BeFalse("{0} is hiragana", @char); - } + result + .Should() + .BeFalse("{0} is hiragana", @char); } + } - [Fact] - public void BeFalseForAllKatakanaChars() + [Fact] + public void BeFalseForAllKatakanaChars() + { + foreach (var @char in CharacterHelper.Katakana) { - foreach (var @char in CharacterHelper.Katakana) - { - var result = @char.IsRomaji(); + var result = @char.IsRomaji(); - result - .Should() - .BeFalse("{0} is katakana", @char); - } + result + .Should() + .BeFalse("{0} is katakana", @char); } + } - [Fact] - public void BeFalseForKanjiChars() + [Fact] + public void BeFalseForKanjiChars() + { + foreach (var @char in CharacterHelper.Kanji()) { - foreach (var @char in CharacterHelper.Kanji()) - { - var result = @char.IsRomaji(); + var result = @char.IsRomaji(); - result - .Should() - .BeFalse("{0} is kanji", @char); - } + result + .Should() + .BeFalse("{0} is kanji", @char); } } -} +} \ No newline at end of file diff --git a/tests/Extensions/StringExtensionsTests/HasHiraganaShould.cs b/tests/Extensions/StringExtensionsTests/HasHiraganaShould.cs index 8387961..7e0e9cc 100644 --- a/tests/Extensions/StringExtensionsTests/HasHiraganaShould.cs +++ b/tests/Extensions/StringExtensionsTests/HasHiraganaShould.cs @@ -1,73 +1,68 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class HasHiraganaShould { - public class HasHiraganaShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void ReturnFalseIsNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void ReturnFalseIsNullOrEmpty(string input) - { - var result = input.HasHiragana(); + var result = input.HasHiragana(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); + } - [Fact] - public void ReturnTrueIfHasHiragana() - { - const string input = "textひらがな"; + [Fact] + public void ReturnTrueIfHasHiragana() + { + const string input = "textひらがな"; - var result = input.HasHiragana(); + var result = input.HasHiragana(); - result - .Should() - .BeTrue(); - } + result + .Should() + .BeTrue(); + } - [Fact] - public void ReturnFalseIfKatakana() - { - const string input = "textカタカナ"; + [Fact] + public void ReturnFalseIfKatakana() + { + const string input = "textカタカナ"; - var result = input.HasHiragana(); + var result = input.HasHiragana(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); + } - [Fact] - public void ReturnFalseIfKanji() - { - const string input = "text漢字"; + [Fact] + public void ReturnFalseIfKanji() + { + const string input = "text漢字"; - var result = input.HasHiragana(); + var result = input.HasHiragana(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); + } - [Fact] - public void ReturnFalseForRomaji() - { - const string input = "random text"; + [Fact] + public void ReturnFalseForRomaji() + { + const string input = "random text"; - var result = input.HasHiragana(); + var result = input.HasHiragana(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); } -} +} \ No newline at end of file diff --git a/tests/Extensions/StringExtensionsTests/HasKanaOrKanjiShould.cs b/tests/Extensions/StringExtensionsTests/HasKanaOrKanjiShould.cs index e859f5e..fe37d3e 100644 --- a/tests/Extensions/StringExtensionsTests/HasKanaOrKanjiShould.cs +++ b/tests/Extensions/StringExtensionsTests/HasKanaOrKanjiShould.cs @@ -1,77 +1,72 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class HasKanaOrKanjiShould { - public class HasKanaOrKanjiShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void ReturnFalseIsNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void ReturnFalseIsNullOrEmpty(string input) - { - input - .Should() - .BeNullOrEmpty(); - - var result = input.HasKanaOrKanji(); - - result - .Should() - .BeFalse(); - } - - [Fact] - public void ReturnTrueIfHasHiragana() - { - const string input = "textひらがな"; - - var result = input.HasKanaOrKanji(); - - result - .Should() - .BeTrue(); - } - - [Fact] - public void ReturnTrueIfKatakana() - { - const string input = "textカタカナ"; - - var result = input.HasKanaOrKanji(); - - result - .Should() - .BeTrue(); - } - - [Fact] - public void ReturnTrueIfKanji() - { - const string input = "text漢字"; - - var result = input.HasKanaOrKanji(); - - result - .Should() - .BeTrue(); - } - - [Fact] - public void ReturnFalseForRomaji() - { - const string input = "random text"; - - var result = input.HasKanaOrKanji(); - - result - .Should() - .BeFalse(); - } + input + .Should() + .BeNullOrEmpty(); + + var result = input.HasKanaOrKanji(); + + result + .Should() + .BeFalse(); + } + + [Fact] + public void ReturnTrueIfHasHiragana() + { + const string input = "textひらがな"; + + var result = input.HasKanaOrKanji(); + + result + .Should() + .BeTrue(); + } + + [Fact] + public void ReturnTrueIfKatakana() + { + const string input = "textカタカナ"; + + var result = input.HasKanaOrKanji(); + + result + .Should() + .BeTrue(); + } + + [Fact] + public void ReturnTrueIfKanji() + { + const string input = "text漢字"; + + var result = input.HasKanaOrKanji(); + + result + .Should() + .BeTrue(); + } + + [Fact] + public void ReturnFalseForRomaji() + { + const string input = "random text"; + + var result = input.HasKanaOrKanji(); + + result + .Should() + .BeFalse(); } -} +} \ No newline at end of file diff --git a/tests/Extensions/StringExtensionsTests/HasKanaShould.cs b/tests/Extensions/StringExtensionsTests/HasKanaShould.cs index a6b8080..51f15fa 100644 --- a/tests/Extensions/StringExtensionsTests/HasKanaShould.cs +++ b/tests/Extensions/StringExtensionsTests/HasKanaShould.cs @@ -1,77 +1,72 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class HasKanaShould { - public class HasKanaShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void ReturnFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void ReturnFalseIfNullOrEmpty(string input) - { - input - .Should() - .BeNullOrEmpty(); - - var result = input.HasKana(); - - result - .Should() - .BeFalse(); - } - - [Fact] - public void ReturnTrueIfHasHiragana() - { - const string input = "textひらがな"; - - var result = input.HasKana(); - - result - .Should() - .BeTrue(); - } - - [Fact] - public void ReturnTrueIfKatakana() - { - const string input = "textカタカナ"; - - var result = input.HasKana(); - - result - .Should() - .BeTrue(); - } - - [Fact] - public void ReturnFalseIfKanji() - { - const string input = "text漢字"; - - var result = input.HasKana(); - - result - .Should() - .BeFalse(); - } - - [Fact] - public void ReturnFalseForRomaji() - { - const string input = "random text"; - - var result = input.HasKana(); - - result - .Should() - .BeFalse(); - } + input + .Should() + .BeNullOrEmpty(); + + var result = input.HasKana(); + + result + .Should() + .BeFalse(); + } + + [Fact] + public void ReturnTrueIfHasHiragana() + { + const string input = "textひらがな"; + + var result = input.HasKana(); + + result + .Should() + .BeTrue(); + } + + [Fact] + public void ReturnTrueIfKatakana() + { + const string input = "textカタカナ"; + + var result = input.HasKana(); + + result + .Should() + .BeTrue(); + } + + [Fact] + public void ReturnFalseIfKanji() + { + const string input = "text漢字"; + + var result = input.HasKana(); + + result + .Should() + .BeFalse(); + } + + [Fact] + public void ReturnFalseForRomaji() + { + const string input = "random text"; + + var result = input.HasKana(); + + result + .Should() + .BeFalse(); } -} +} \ No newline at end of file diff --git a/tests/Extensions/StringExtensionsTests/HasKanjiShould.cs b/tests/Extensions/StringExtensionsTests/HasKanjiShould.cs index 6f337c2..a516708 100644 --- a/tests/Extensions/StringExtensionsTests/HasKanjiShould.cs +++ b/tests/Extensions/StringExtensionsTests/HasKanjiShould.cs @@ -1,103 +1,97 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class HasKanjiShould { - public class HasKanjiShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void BeFalseIfNullOrEmpty(string input) - { - var result = input.HasKanji(); - - result - .Should() - .BeFalse("{0} is null or empty", input); - } - - [Fact] - public void BeTrueIfOnlyKanji() - { - var input = WordHelper.GenerateKanji(); - var result = input.HasKanji(); - - result - .Should() - .BeTrue("{0} is kanji", input); - } - - [Fact] - public void BeTrueIfKanjiAndHiragana() - { - var input = WordHelper.GenerateKanji() + WordHelper.GenerateHiragana(); - var result = input.HasKanji(); - - result - .Should() - .BeTrue("{0} has kanji", input); - } - - [Fact] - public void BeTrueIfKanjiAndKatakana() - { - var input = WordHelper.GenerateKanji() + WordHelper.GenerateKatakana(); - var result = input.HasKanji(); - - result - .Should() - .BeTrue("{0} has kanji", input); - } - - [Fact] - public void BeTrueIfKanjiAndRomaji() - { - var input = WordHelper.GenerateKanji() + WordHelper.GenerateRomaji(); - var result = input.HasKanji(); - - result - .Should() - .BeTrue("{0} has kanji", input); - } - - [Fact] - public void BeFalseIfOnlyHiragana() - { - var input = WordHelper.GenerateHiragana(); - var result = input.HasKanji(); - - result - .Should() - .BeFalse("{0} is hiragana", input); - } - - [Fact] - public void BeFalseIfOnlyKatakana() - { - var input = WordHelper.GenerateKatakana(); - var result = input.HasKanji(); - - result - .Should() - .BeFalse("{0} is katakana", input); - } - - [Fact] - public void BeFalseIfOnlyRomaji() - { - var input = WordHelper.GenerateRomaji(); - var result = input.HasKanji(); - - result - .Should() - .BeFalse("{0} is romaji", input); - } + var result = input.HasKanji(); + + result + .Should() + .BeFalse("{0} is null or empty", input); + } + + [Fact] + public void BeTrueIfOnlyKanji() + { + var input = WordHelper.GenerateKanji(); + var result = input.HasKanji(); + + result + .Should() + .BeTrue("{0} is kanji", input); + } + + [Fact] + public void BeTrueIfKanjiAndHiragana() + { + var input = WordHelper.GenerateKanji() + WordHelper.GenerateHiragana(); + var result = input.HasKanji(); + + result + .Should() + .BeTrue("{0} has kanji", input); + } + + [Fact] + public void BeTrueIfKanjiAndKatakana() + { + var input = WordHelper.GenerateKanji() + WordHelper.GenerateKatakana(); + var result = input.HasKanji(); + + result + .Should() + .BeTrue("{0} has kanji", input); + } + + [Fact] + public void BeTrueIfKanjiAndRomaji() + { + var input = WordHelper.GenerateKanji() + WordHelper.GenerateRomaji(); + var result = input.HasKanji(); + + result + .Should() + .BeTrue("{0} has kanji", input); + } + + [Fact] + public void BeFalseIfOnlyHiragana() + { + var input = WordHelper.GenerateHiragana(); + var result = input.HasKanji(); + + result + .Should() + .BeFalse("{0} is hiragana", input); + } + + [Fact] + public void BeFalseIfOnlyKatakana() + { + var input = WordHelper.GenerateKatakana(); + var result = input.HasKanji(); + + result + .Should() + .BeFalse("{0} is katakana", input); + } + + [Fact] + public void BeFalseIfOnlyRomaji() + { + var input = WordHelper.GenerateRomaji(); + var result = input.HasKanji(); + + result + .Should() + .BeFalse("{0} is romaji", input); } -} +} \ No newline at end of file diff --git a/tests/Extensions/StringExtensionsTests/HasKatakanaShould.cs b/tests/Extensions/StringExtensionsTests/HasKatakanaShould.cs index 07202ef..bcf7d0f 100644 --- a/tests/Extensions/StringExtensionsTests/HasKatakanaShould.cs +++ b/tests/Extensions/StringExtensionsTests/HasKatakanaShould.cs @@ -1,77 +1,72 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class HasKatakanaShould { - public class HasKatakanaShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void ReturnFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void ReturnFalseIfNullOrEmpty(string input) - { - input - .Should() - .BeNullOrEmpty(); - - var result = input.HasKatakana(); - - result - .Should() - .BeFalse(); - } - - [Fact] - public void ReturnFalseIfHiragana() - { - const string input = "textひらがな"; - - var result = input.HasKatakana(); - - result - .Should() - .BeFalse(); - } - - [Fact] - public void ReturnTrueIfKatakana() - { - const string input = "textカタカナ"; - - var result = input.HasKatakana(); - - result - .Should() - .BeTrue(); - } - - [Fact] - public void ReturnFalseIfKanji() - { - const string input = "text漢字"; - - var result = input.HasKatakana(); - - result - .Should() - .BeFalse(); - } - - [Fact] - public void ReturnFalseIfRomaji() - { - const string input = "random text"; - - var result = input.HasKatakana(); - - result - .Should() - .BeFalse(); - } + input + .Should() + .BeNullOrEmpty(); + + var result = input.HasKatakana(); + + result + .Should() + .BeFalse(); + } + + [Fact] + public void ReturnFalseIfHiragana() + { + const string input = "textひらがな"; + + var result = input.HasKatakana(); + + result + .Should() + .BeFalse(); + } + + [Fact] + public void ReturnTrueIfKatakana() + { + const string input = "textカタカナ"; + + var result = input.HasKatakana(); + + result + .Should() + .BeTrue(); + } + + [Fact] + public void ReturnFalseIfKanji() + { + const string input = "text漢字"; + + var result = input.HasKatakana(); + + result + .Should() + .BeFalse(); + } + + [Fact] + public void ReturnFalseIfRomaji() + { + const string input = "random text"; + + var result = input.HasKatakana(); + + result + .Should() + .BeFalse(); } -} +} \ No newline at end of file diff --git a/tests/Extensions/StringExtensionsTests/HasRomajiShould.cs b/tests/Extensions/StringExtensionsTests/HasRomajiShould.cs index ea42117..dbdeccb 100644 --- a/tests/Extensions/StringExtensionsTests/HasRomajiShould.cs +++ b/tests/Extensions/StringExtensionsTests/HasRomajiShould.cs @@ -1,73 +1,68 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public sealed class HasRomajiShould { - public sealed class HasRomajiShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void ReturnFalseIsNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void ReturnFalseIsNullOrEmpty(string input) - { - var result = input.HasRomaji(); + var result = input.HasRomaji(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); + } - [Fact] - public void ReturnTrueIfHasRomaji() - { - const string input = "ひらがなtext"; + [Fact] + public void ReturnTrueIfHasRomaji() + { + const string input = "ひらがなtext"; - var result = input.HasRomaji(); + var result = input.HasRomaji(); - result - .Should() - .BeTrue(); - } + result + .Should() + .BeTrue(); + } - [Fact] - public void ReturnTrueIfHiragana() - { - const string input = "ひらがな"; + [Fact] + public void ReturnTrueIfHiragana() + { + const string input = "ひらがな"; - var result = input.HasRomaji(); + var result = input.HasRomaji(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); + } - [Fact] - public void ReturnTrueIfKatakana() - { - const string input = "カタカナ"; + [Fact] + public void ReturnTrueIfKatakana() + { + const string input = "カタカナ"; - var result = input.HasRomaji(); + var result = input.HasRomaji(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); + } - [Fact] - public void ReturnTrueIfKanji() - { - const string input = "漢字"; + [Fact] + public void ReturnTrueIfKanji() + { + const string input = "漢字"; - var result = input.HasRomaji(); + var result = input.HasRomaji(); - result - .Should() - .BeFalse(); - } + result + .Should() + .BeFalse(); } -} +} \ No newline at end of file diff --git a/tests/Extensions/StringExtensionsTests/IsHiraganaShould.cs b/tests/Extensions/StringExtensionsTests/IsHiraganaShould.cs index 6872f49..346a61a 100644 --- a/tests/Extensions/StringExtensionsTests/IsHiraganaShould.cs +++ b/tests/Extensions/StringExtensionsTests/IsHiraganaShould.cs @@ -1,70 +1,76 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class IsHiraganaShould { - public class IsHiraganaShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void BeFalseIfNullOrEmpty(string input) - { - var result = input.IsHiragana(); + var result = input.IsHiragana(); - result - .Should() - .BeFalse("{0} is null or empty", input); - } + result + .Should() + .BeFalse("{0} is null or empty", input); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeTrueIfNullOrEmpty(string input) + { + var result = input.IsHiragana(true); - [Fact] - public void BeTrueIfOnlyHiragana() - { - var input = WordHelper.GenerateHiragana(); - var result = input.IsHiragana(); + result + .Should() + .BeTrue("{0} is null or empty", input); + } - result - .Should() - .BeTrue("{0} is hiragana", input); - } + [Fact] + public void BeTrueIfOnlyHiragana() + { + var input = WordHelper.GenerateHiragana(); + var result = input.IsHiragana(); - [Fact] - public void BeFalseIfHasKatakana() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana(); - var result = input.IsHiragana(); + result + .Should() + .BeTrue("{0} is hiragana", input); + } - result - .Should() - .BeFalse("{0} has katakana", input); - } + [Fact] + public void BeFalseIfHasKatakana() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana(); + var result = input.IsHiragana(); - [Fact] - public void BeFalseIfHasKanji() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKanji(); - var result = input.IsHiragana(); + result + .Should() + .BeFalse("{0} has katakana", input); + } - result - .Should() - .BeFalse("{0} has kanji", input); - } + [Fact] + public void BeFalseIfHasKanji() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKanji(); + var result = input.IsHiragana(); - [Fact] - public void BeFalseIfHasRomaji() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateRomaji(); - var result = input.IsHiragana(); + result + .Should() + .BeFalse("{0} has kanji", input); + } + + [Fact] + public void BeFalseIfHasRomaji() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateRomaji(); + var result = input.IsHiragana(); - result - .Should() - .BeFalse("{0} has romaji", input); - } + result + .Should() + .BeFalse("{0} has romaji", input); } } diff --git a/tests/Extensions/StringExtensionsTests/IsKanaOrKanjiShould.cs b/tests/Extensions/StringExtensionsTests/IsKanaOrKanjiShould.cs index ed0ae15..8367a1a 100644 --- a/tests/Extensions/StringExtensionsTests/IsKanaOrKanjiShould.cs +++ b/tests/Extensions/StringExtensionsTests/IsKanaOrKanjiShould.cs @@ -1,103 +1,109 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class IsKanaOrKanjiShould { - public class IsKanaOrKanjiShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void BeFalseIfNullOrEmpty(string input) - { - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeFalse("{0} is null or empty", input); - } - - [Fact] - public void BeTrueIfOnlyHiragana() - { - var input = WordHelper.GenerateHiragana(); - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeTrue("{0} is hiragana", input); - } - - [Fact] - public void BeTrueIfOnlyKatakana() - { - var input = WordHelper.GenerateKatakana(); - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeTrue("{0} is katakana", input); - } - - [Fact] - public void BeTrueIfHiraganaAndKatakana() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana(); - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeTrue("{0} is hiragana and katakana", input); - } - - [Fact] - public void BeTrueIfHiraganaAndKanji() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKanji(); - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeTrue("{0} is hiragana and kanji", input); - } - - [Fact] - public void BeTrueIfKatakanaAndKanji() - { - var input = WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeTrue("{0} is katakana and kanji", input); - } - - [Fact] - public void BeTrueIfHiraganaKatakanaAndKanji() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeTrue("{0} is hiragana, katakana and kanji", input); - } - - [Fact] - public void BeTrueIfHasRomaji() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateKanji() + WordHelper.GenerateRomaji(); - var result = input.IsKanaOrKanji(); - - result - .Should() - .BeFalse("{0} has romaji", input); - } + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeFalse("{0} is null or empty", input); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeTrueIfNullOrEmpty(string input) + { + var result = input.IsKanaOrKanji(true); + + result + .Should() + .BeTrue("{0} is null or empty", input); + } + + [Fact] + public void BeTrueIfOnlyHiragana() + { + var input = WordHelper.GenerateHiragana(); + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeTrue("{0} is hiragana", input); + } + + [Fact] + public void BeTrueIfOnlyKatakana() + { + var input = WordHelper.GenerateKatakana(); + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeTrue("{0} is katakana", input); + } + + [Fact] + public void BeTrueIfHiraganaAndKatakana() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana(); + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeTrue("{0} is hiragana and katakana", input); + } + + [Fact] + public void BeTrueIfHiraganaAndKanji() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKanji(); + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeTrue("{0} is hiragana and kanji", input); + } + + [Fact] + public void BeTrueIfKatakanaAndKanji() + { + var input = WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeTrue("{0} is katakana and kanji", input); + } + + [Fact] + public void BeTrueIfHiraganaKatakanaAndKanji() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeTrue("{0} is hiragana, katakana and kanji", input); + } + + [Fact] + public void BeTrueIfHasRomaji() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateKanji() + WordHelper.GenerateRomaji(); + var result = input.IsKanaOrKanji(); + + result + .Should() + .BeFalse("{0} has romaji", input); } } diff --git a/tests/Extensions/StringExtensionsTests/IsKanaShould.cs b/tests/Extensions/StringExtensionsTests/IsKanaShould.cs index d195285..cabaace 100644 --- a/tests/Extensions/StringExtensionsTests/IsKanaShould.cs +++ b/tests/Extensions/StringExtensionsTests/IsKanaShould.cs @@ -1,81 +1,87 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class IsKanaShould { - public class IsKanaShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void BeFalseIfNullOrEmpty(string input) - { - var result = input.IsKana(); + var result = input.IsKana(); - result - .Should() - .BeFalse("{0} is null or empty", input); - } + result + .Should() + .BeFalse("{0} is null or empty", input); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeTrueIfNullOrEmpty(string input) + { + var result = input.IsKana(true); - [Fact] - public void BeTrueIfOnlyHiragana() - { - var input = WordHelper.GenerateHiragana(); - var result = input.IsKana(); + result + .Should() + .BeTrue("{0} is null or empty", input); + } - result - .Should() - .BeTrue("{0} is hiragana", input); - } + [Fact] + public void BeTrueIfOnlyHiragana() + { + var input = WordHelper.GenerateHiragana(); + var result = input.IsKana(); - [Fact] - public void BeTrueIfOnlyKatakana() - { - var input = WordHelper.GenerateKatakana(); - var result = input.IsKana(); + result + .Should() + .BeTrue("{0} is hiragana", input); + } - result - .Should() - .BeTrue("{0} is katakana", input); - } + [Fact] + public void BeTrueIfOnlyKatakana() + { + var input = WordHelper.GenerateKatakana(); + var result = input.IsKana(); - [Fact] - public void BeTrueIfHiraganaAndKatakana() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana(); - var result = input.IsKana(); + result + .Should() + .BeTrue("{0} is katakana", input); + } - result - .Should() - .BeTrue("{0} is hiragana and katakana", input); - } + [Fact] + public void BeTrueIfHiraganaAndKatakana() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana(); + var result = input.IsKana(); + + result + .Should() + .BeTrue("{0} is hiragana and katakana", input); + } - [Fact] - public void BeFalseIfHasKanji() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); - var result = input.IsKana(); + [Fact] + public void BeFalseIfHasKanji() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); + var result = input.IsKana(); - result - .Should() - .BeFalse("{0} has kanji", input); - } + result + .Should() + .BeFalse("{0} has kanji", input); + } - [Fact] - public void BeFalseIfHasRomaji() - { - var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateRomaji(); - var result = input.IsKana(); + [Fact] + public void BeFalseIfHasRomaji() + { + var input = WordHelper.GenerateHiragana() + WordHelper.GenerateKatakana() + WordHelper.GenerateRomaji(); + var result = input.IsKana(); - result - .Should() - .BeFalse("{0} has kanji", input); - } + result + .Should() + .BeFalse("{0} has kanji", input); } } diff --git a/tests/Extensions/StringExtensionsTests/IsKanjiShould.cs b/tests/Extensions/StringExtensionsTests/IsKanjiShould.cs index c4579a3..2d2b300 100644 --- a/tests/Extensions/StringExtensionsTests/IsKanjiShould.cs +++ b/tests/Extensions/StringExtensionsTests/IsKanjiShould.cs @@ -1,70 +1,76 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class IsKanjiShould { - public class IsKanjiShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void BeFalseIfNullOrEmpty(string input) - { - var result = input.IsKanji(); + var result = input.IsKanji(); - result - .Should() - .BeFalse("{0} is null or empty", input); - } + result + .Should() + .BeFalse("{0} is null or empty", input); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeTrueIfNullOrEmpty(string input) + { + var result = input.IsKanji(true); - [Fact] - public void BeTrueIfOnlyKanji() - { - var input = WordHelper.GenerateKanji(); - var result = input.IsKanji(); + result + .Should() + .BeTrue("{0} is null or empty", input); + } - result - .Should() - .BeTrue("{0} is kanji", input); - } + [Fact] + public void BeTrueIfOnlyKanji() + { + var input = WordHelper.GenerateKanji(); + var result = input.IsKanji(); - [Fact] - public void BeFalseIfHasHiragana() - { - var input = WordHelper.GenerateKanji() + WordHelper.GenerateHiragana(); - var result = input.IsKanji(); + result + .Should() + .BeTrue("{0} is kanji", input); + } - result - .Should() - .BeFalse("{0} has hiragana", input); - } + [Fact] + public void BeFalseIfHasHiragana() + { + var input = WordHelper.GenerateKanji() + WordHelper.GenerateHiragana(); + var result = input.IsKanji(); - [Fact] - public void BeFalseIfHasKatakana() - { - var input = WordHelper.GenerateKanji() + WordHelper.GenerateKatakana(); - var result = input.IsKanji(); + result + .Should() + .BeFalse("{0} has hiragana", input); + } - result - .Should() - .BeFalse("{0} has katakana", input); - } + [Fact] + public void BeFalseIfHasKatakana() + { + var input = WordHelper.GenerateKanji() + WordHelper.GenerateKatakana(); + var result = input.IsKanji(); - [Fact] - public void BeFalseIfHasRomaji() - { - var input = WordHelper.GenerateKanji() + WordHelper.GenerateRomaji(); - var result = input.IsKanji(); + result + .Should() + .BeFalse("{0} has katakana", input); + } + + [Fact] + public void BeFalseIfHasRomaji() + { + var input = WordHelper.GenerateKanji() + WordHelper.GenerateRomaji(); + var result = input.IsKanji(); - result - .Should() - .BeFalse("{0} has romaji", input); - } + result + .Should() + .BeFalse("{0} has romaji", input); } } diff --git a/tests/Extensions/StringExtensionsTests/IsKatakanaShould.cs b/tests/Extensions/StringExtensionsTests/IsKatakanaShould.cs index 930308e..acbf51c 100644 --- a/tests/Extensions/StringExtensionsTests/IsKatakanaShould.cs +++ b/tests/Extensions/StringExtensionsTests/IsKatakanaShould.cs @@ -1,70 +1,76 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public class IsKatakanaShould { - public class IsKatakanaShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeFalseIfNullOrEmpty(string input) { - [Theory] - [InlineData(null)] - [InlineData("")] - public void BeFalseIfNullOrEmpty(string input) - { - var result = input.IsKatakana(); + var result = input.IsKatakana(); - result - .Should() - .BeFalse("{0} is null or empty", input); - } + result + .Should() + .BeFalse("{0} is null or empty", input); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeTrueIfNullOrEmpty(string input) + { + var result = input.IsKatakana(true); - [Fact] - public void BeTrueIfOnlyKatakana() - { - var input = WordHelper.GenerateKatakana(); - var result = input.IsKatakana(); + result + .Should() + .BeTrue("{0} is null or empty", input); + } - result - .Should() - .BeTrue("{0} is katakana", input); - } + [Fact] + public void BeTrueIfOnlyKatakana() + { + var input = WordHelper.GenerateKatakana(); + var result = input.IsKatakana(); - [Fact] - public void BeFalseIfHasHiragana() - { - var input = WordHelper.GenerateKatakana() + WordHelper.GenerateHiragana(); - var result = input.IsKatakana(); + result + .Should() + .BeTrue("{0} is katakana", input); + } - result - .Should() - .BeFalse("{0} has hiragana", input); - } + [Fact] + public void BeFalseIfHasHiragana() + { + var input = WordHelper.GenerateKatakana() + WordHelper.GenerateHiragana(); + var result = input.IsKatakana(); - [Fact] - public void BeFalseIfHasKanji() - { - var input = WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); - var result = input.IsKatakana(); + result + .Should() + .BeFalse("{0} has hiragana", input); + } - result - .Should() - .BeFalse("{0} has kanji", input); - } + [Fact] + public void BeFalseIfHasKanji() + { + var input = WordHelper.GenerateKatakana() + WordHelper.GenerateKanji(); + var result = input.IsKatakana(); - [Fact] - public void BeFalseIfHasRomaji() - { - var input = WordHelper.GenerateKatakana() + WordHelper.GenerateRomaji(); - var result = input.IsKatakana(); + result + .Should() + .BeFalse("{0} has kanji", input); + } + + [Fact] + public void BeFalseIfHasRomaji() + { + var input = WordHelper.GenerateKatakana() + WordHelper.GenerateRomaji(); + var result = input.IsKatakana(); - result - .Should() - .BeFalse("{0} has romaji", input); - } + result + .Should() + .BeFalse("{0} has romaji", input); } } diff --git a/tests/Extensions/StringExtensionsTests/IsRomajiShould.cs b/tests/Extensions/StringExtensionsTests/IsRomajiShould.cs index 2a787a3..3ca809f 100644 --- a/tests/Extensions/StringExtensionsTests/IsRomajiShould.cs +++ b/tests/Extensions/StringExtensionsTests/IsRomajiShould.cs @@ -1,71 +1,76 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using FluentAssertions; -using MyNihongo.KanaDetector.Extensions; -using MyNihongo.KanaDetector.Tests.TestHelpers; -using Xunit; +namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests; -namespace MyNihongo.KanaDetector.Tests.Extensions.StringExtensionsTests +public sealed class IsRomajiShould { - public sealed class IsRomajiShould + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeFalseIfNullOrEmpty(string input) { + var result = input.IsRomaji(); - [Theory] - [InlineData(null)] - [InlineData("")] - public void BeFalseIfNullOrEmpty(string input) - { - var result = input.IsRomaji(); + result + .Should() + .BeFalse("{0} is null or empty", input); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public void BeTrueIfNullOrEmpty(string input) + { + var result = input.IsRomaji(true); - result - .Should() - .BeFalse("{0} is null or empty", input); - } + result + .Should() + .BeTrue("{0} is null or empty", input); + } - [Fact] - public void BeTrueIfOnlyRomaji() - { - var input = WordHelper.GenerateRomaji(); - var result = input.IsRomaji(); + [Fact] + public void BeTrueIfOnlyRomaji() + { + var input = WordHelper.GenerateRomaji(); + var result = input.IsRomaji(); - result - .Should() - .BeTrue("{0} is romaji", input); - } + result + .Should() + .BeTrue("{0} is romaji", input); + } - [Fact] - public void BeFalseIfHasHiragana() - { - var input = WordHelper.GenerateRomaji() + WordHelper.GenerateHiragana(); - var result = input.IsRomaji(); + [Fact] + public void BeFalseIfHasHiragana() + { + var input = WordHelper.GenerateRomaji() + WordHelper.GenerateHiragana(); + var result = input.IsRomaji(); - result - .Should() - .BeFalse("{0} has hiragana", input); - } + result + .Should() + .BeFalse("{0} has hiragana", input); + } - [Fact] - public void BeFalseIfHasKatakana() - { - var input = WordHelper.GenerateRomaji() + WordHelper.GenerateKatakana(); - var result = input.IsRomaji(); + [Fact] + public void BeFalseIfHasKatakana() + { + var input = WordHelper.GenerateRomaji() + WordHelper.GenerateKatakana(); + var result = input.IsRomaji(); - result - .Should() - .BeFalse("{0} has katakana", input); - } + result + .Should() + .BeFalse("{0} has katakana", input); + } - [Fact] - public void BeFalseIfHasKanji() - { - var input = WordHelper.GenerateRomaji() + WordHelper.GenerateKanji(); - var result = input.IsRomaji(); + [Fact] + public void BeFalseIfHasKanji() + { + var input = WordHelper.GenerateRomaji() + WordHelper.GenerateKanji(); + var result = input.IsRomaji(); - result - .Should() - .BeFalse("{0} has kanji", input); - } + result + .Should() + .BeFalse("{0} has kanji", input); } } diff --git a/tests/MyNihongo.KanaDetector.Tests.csproj b/tests/MyNihongo.KanaDetector.Tests.csproj index 74705c2..a94fc7d 100644 --- a/tests/MyNihongo.KanaDetector.Tests.csproj +++ b/tests/MyNihongo.KanaDetector.Tests.csproj @@ -1,19 +1,20 @@ - net5.0 + net6.0 + enable false - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/TestHelpers/CharacterHelper.cs b/tests/TestHelpers/CharacterHelper.cs index e008630..616468e 100644 --- a/tests/TestHelpers/CharacterHelper.cs +++ b/tests/TestHelpers/CharacterHelper.cs @@ -1,62 +1,57 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using System; -using System.Collections.Generic; -using MyNihongo.KanaDetector.Resources; +namespace MyNihongo.KanaDetector.Tests.TestHelpers; -namespace MyNihongo.KanaDetector.Tests.TestHelpers +public static class CharacterHelper { - public static class CharacterHelper - { - private static readonly Lazy> HiraganaLazy = - new(() => new List - { - 'ぁ','あ','ぃ','い','ぅ','う','ぇ','え','ぉ','お','か','が','き','ぎ','く', - 'ぐ','け','げ','こ','ご','さ','ざ','し','じ','す','ず','せ','ぜ','そ','ぞ','た', - 'だ','ち','ぢ','っ','つ','づ','て','で','と','ど','な','に','ぬ','ね','の','は', - 'ば','ぱ','ひ','び','ぴ','ふ','ぶ','ぷ','へ','べ','ぺ','ほ','ぼ','ぽ','ま','み', - 'む','め','も','ゃ','や','ゅ','ゆ','ょ','よ','ら','り','る','れ','ろ','ゎ','わ', - 'ゐ','ゑ','を','ん','ゔ','ゕ','ゖ' - }); - - private static readonly Lazy> KatakanaLazy = - new(() => new List - { - 'ァ','ア','ィ','イ','ゥ','ウ','ェ','エ','ォ','オ','カ','ガ','キ','ギ','ク', - 'グ','ケ','ゲ','コ','ゴ','サ','ザ','シ','ジ','ス','ズ','セ','ゼ','ソ','ゾ','タ', - 'ダ','チ','ヂ','ッ','ツ','ヅ','テ','デ','ト','ド','ナ','ニ','ヌ','ネ','ノ','ハ', - 'バ','パ','ヒ','ビ','ピ','フ','ブ','プ','ヘ','ベ','ペ','ホ','ボ','ポ','マ','ミ', - 'ム','メ','モ','ャ','ヤ','ュ','ユ','ョ','ヨ','ラ','リ','ル','レ','ロ','ヮ','ワ', - 'ヰ','ヱ','ヲ','ン','ヴ','ヵ','ヶ','ヷ','ヸ','ヹ','ヺ', - '・','ー' - }); - - private static readonly Lazy> RomajiLazy = - new(() => new List - { - 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x' ,'y','z', - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X' ,'Y','Z', - 'ā', 'ī', 'ū', 'ē', 'ō', - 'Ā', 'Ī', 'Ū', 'Ē', 'Ō' - }); - - public static IReadOnlyList Hiragana => HiraganaLazy.Value; - - public static IReadOnlyList Katakana => KatakanaLazy.Value; - - public static IReadOnlyList Romaji => RomajiLazy.Value; - - public static IEnumerable Kanji() + private static readonly Lazy> HiraganaLazy = + new(() => new List + { + 'ぁ','あ','ぃ','い','ぅ','う','ぇ','え','ぉ','お','か','が','き','ぎ','く', + 'ぐ','け','げ','こ','ご','さ','ざ','し','じ','す','ず','せ','ぜ','そ','ぞ','た', + 'だ','ち','ぢ','っ','つ','づ','て','で','と','ど','な','に','ぬ','ね','の','は', + 'ば','ぱ','ひ','び','ぴ','ふ','ぶ','ぷ','へ','べ','ぺ','ほ','ぼ','ぽ','ま','み', + 'む','め','も','ゃ','や','ゅ','ゆ','ょ','よ','ら','り','る','れ','ろ','ゎ','わ', + 'ゐ','ゑ','を','ん','ゔ','ゕ','ゖ' + }); + + private static readonly Lazy> KatakanaLazy = + new(() => new List { - for (var i = Constants.Kanji.Start; i <= Constants.Kanji.End; i++) - yield return Convert.ToChar(i); + 'ァ','ア','ィ','イ','ゥ','ウ','ェ','エ','ォ','オ','カ','ガ','キ','ギ','ク', + 'グ','ケ','ゲ','コ','ゴ','サ','ザ','シ','ジ','ス','ズ','セ','ゼ','ソ','ゾ','タ', + 'ダ','チ','ヂ','ッ','ツ','ヅ','テ','デ','ト','ド','ナ','ニ','ヌ','ネ','ノ','ハ', + 'バ','パ','ヒ','ビ','ピ','フ','ブ','プ','ヘ','ベ','ペ','ホ','ボ','ポ','マ','ミ', + 'ム','メ','モ','ャ','ヤ','ュ','ユ','ョ','ヨ','ラ','リ','ル','レ','ロ','ヮ','ワ', + 'ヰ','ヱ','ヲ','ン','ヴ','ヵ','ヶ','ヷ','ヸ','ヹ','ヺ', + '・','ー' + }); + + private static readonly Lazy> RomajiLazy = + new(() => new List + { + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x' ,'y','z', + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X' ,'Y','Z', + 'ā', 'ī', 'ū', 'ē', 'ō', + 'Ā', 'Ī', 'Ū', 'Ē', 'Ō' + }); + + public static IReadOnlyList Hiragana => HiraganaLazy.Value; + + public static IReadOnlyList Katakana => KatakanaLazy.Value; + + public static IReadOnlyList Romaji => RomajiLazy.Value; + + public static IEnumerable Kanji() + { + for (var i = Constants.Kanji.Start; i <= Constants.Kanji.End; i++) + yield return Convert.ToChar(i); - for (var i = Constants.Kanji.RareStart; i <= Constants.Kanji.RareEnd; i++) - yield return Convert.ToChar(i); + for (var i = Constants.Kanji.RareStart; i <= Constants.Kanji.RareEnd; i++) + yield return Convert.ToChar(i); - yield return Convert.ToChar(Constants.Kanji.IterationMark); - } + yield return Convert.ToChar(Constants.Kanji.IterationMark); } } diff --git a/tests/TestHelpers/WordHelper.cs b/tests/TestHelpers/WordHelper.cs index 53a5732..01dd287 100644 --- a/tests/TestHelpers/WordHelper.cs +++ b/tests/TestHelpers/WordHelper.cs @@ -1,69 +1,66 @@ /* -* Copyright © 2021 MyNihongo +* Copyright © 2023 MyNihongo */ -using MyNihongo.KanaDetector.Resources; -using System; using System.Security.Cryptography; -namespace MyNihongo.KanaDetector.Tests.TestHelpers +namespace MyNihongo.KanaDetector.Tests.TestHelpers; + +public static class WordHelper { - public static class WordHelper + public static string GenerateHiragana() { - public static string GenerateHiragana() + var length = RandomNumberGenerator.GetInt32(5, 10); + + return string.Create(length, string.Empty, (span, s) => { - var length = RandomNumberGenerator.GetInt32(5, 10); + for (var i = 0; i < length; i++) + span[i] = GetRandomChar(Constants.Kana.HiraganaStart, Constants.Kana.HiraganaEnd); + }); + } - return string.Create(length, string.Empty, (span, s) => - { - for (var i = 0; i < length; i++) - span[i] = GetRandomChar(Constants.Kana.HiraganaStart, Constants.Kana.HiraganaEnd); - }); - } + public static string GenerateKatakana() + { + var length = RandomNumberGenerator.GetInt32(5, 10); - public static string GenerateKatakana() + return string.Create(length, string.Empty, (span, s) => { - var length = RandomNumberGenerator.GetInt32(5, 10); + for (var i = 0; i < length; i++) + span[i] = GetRandomChar(Constants.Kana.KatakanaStart, Constants.Kana.KatakanaEnd); + }); + } - return string.Create(length, string.Empty, (span, s) => - { - for (var i = 0; i < length; i++) - span[i] = GetRandomChar(Constants.Kana.KatakanaStart, Constants.Kana.KatakanaEnd); - }); - } + public static string GenerateKanji() + { + var length = RandomNumberGenerator.GetInt32(5, 10); - public static string GenerateKanji() + return string.Create(length, string.Empty, (span, s) => { - var length = RandomNumberGenerator.GetInt32(5, 10); - - return string.Create(length, string.Empty, (span, s) => + for (var i = 0; i < length; i++) { - for (var i = 0; i < length; i++) - { - var (from, to) = i % 2 == 0 - ? (Constants.Kanji.Start, Constants.Kanji.End) - : (Constants.Kanji.RareStart, Constants.Kanji.RareEnd); + var (from, to) = i % 2 == 0 + ? (Constants.Kanji.Start, Constants.Kanji.End) + : (Constants.Kanji.RareStart, Constants.Kanji.RareEnd); - span[i] = GetRandomChar(from, to); - } - }); - } + span[i] = GetRandomChar(from, to); + } + }); + } - public static string GenerateRomaji() - { - var length = RandomNumberGenerator.GetInt32(5, 10); + public static string GenerateRomaji() + { + var length = RandomNumberGenerator.GetInt32(5, 10); - return string.Create(length, string.Empty, (span, s) => + return string.Create(length, string.Empty, (span, s) => + { + for (var i = 0; i < length; i++) { - for (var i = 0; i < length; i++) - { - var index = RandomNumberGenerator.GetInt32(0, CharacterHelper.Romaji.Count); - span[i] = CharacterHelper.Romaji[index]; - } - }); - } - - private static char GetRandomChar(int fromInclusive, int toInclusive) => - Convert.ToChar(RandomNumberGenerator.GetInt32(fromInclusive, toInclusive + 1)); + var index = RandomNumberGenerator.GetInt32(0, CharacterHelper.Romaji.Count); + span[i] = CharacterHelper.Romaji[index]; + } + }); } -} + + private static char GetRandomChar(int fromInclusive, int toInclusive) => + Convert.ToChar(RandomNumberGenerator.GetInt32(fromInclusive, toInclusive + 1)); +} \ No newline at end of file diff --git a/tests/_Usings.cs b/tests/_Usings.cs new file mode 100644 index 0000000..fc85451 --- /dev/null +++ b/tests/_Usings.cs @@ -0,0 +1,3 @@ +global using FluentAssertions; +global using MyNihongo.KanaDetector.Tests.TestHelpers; +global using Xunit;