From f6a03cfcc872f46e534469919d7f21a16a74ebb1 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 22 May 2024 21:40:16 +0800 Subject: [PATCH] Fix the invalid test name. --- .../CheckBeatmapAvailableTranslatesTest.cs | 52 ++++++++++++------- .../Checks/CheckBeatmapStageInfoTest.cs | 6 +-- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapAvailableTranslatesTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapAvailableTranslatesTest.cs index 3f1126d51..8dd60aaa9 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapAvailableTranslatesTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapAvailableTranslatesTest.cs @@ -49,7 +49,20 @@ public void TestHaveLyricButNoLanguage() } [Test] - public void TestHaveLyricAndLanguage() + public void TestEveryLyricContainsTranslate() + { + var translateLanguages = new List { new("Ja-jp") }; + var beatmap = createTestingBeatmap(translateLanguages, new[] + { + createLyric(new CultureInfo("Ja-jp"), "translate1"), + createLyric(new CultureInfo("Ja-jp"), "translate2"), + }); + + AssertOk(getContext(beatmap)); + } + + [Test] + public void TestCheckMissingTranslate() { // no lyric with translate string. (should have issue) var translateLanguages = new List { new("Ja-jp") }; @@ -75,39 +88,30 @@ public void TestHaveLyricAndLanguage() createLyric(new CultureInfo("Ja-jp"), string.Empty), }); AssertNotOk(getContext(beatmap3)); + } + [Test] + public void TestCheckMissingPartialTranslate() + { // some lyric with translate string. (should have issue) + var translateLanguages = new List { new("Ja-jp") }; var beatmap4 = createTestingBeatmap(translateLanguages, new[] { createLyric(new CultureInfo("Ja-jp"), "translate1"), createLyric(new CultureInfo("Ja-jp")), }); AssertNotOk(getContext(beatmap4)); + } - // every lyric with translate string. (should not have issue) - var beatmap5 = createTestingBeatmap(translateLanguages, new[] - { - createLyric(new CultureInfo("Ja-jp"), "translate1"), - createLyric(new CultureInfo("Ja-jp"), "translate2"), - }); - AssertOk(getContext(beatmap5)); - + [Test] + public void TestCheckContainsNotListedLanguage() + { // lyric translate not listed. (should have issue) var beatmap6 = createTestingBeatmap(null, new[] { createLyric(new CultureInfo("en-US"), "translate1"), }); AssertNotOk(getContext(beatmap6)); - - static Lyric createLyric(CultureInfo? cultureInfo = null, string translate = null!) - { - var lyric = new Lyric(); - if (cultureInfo == null) - return lyric; - - lyric.Translates.Add(cultureInfo, translate); - return lyric; - } } private static IBeatmap createTestingBeatmap(List? translateLanguage, IEnumerable? lyrics) @@ -126,4 +130,14 @@ private static IBeatmap createTestingBeatmap(List? translateLanguag private static BeatmapVerifierContext getContext(IBeatmap beatmap) => new(beatmap, new TestWorkingBeatmap(beatmap)); + + private static Lyric createLyric(CultureInfo? cultureInfo = null, string translate = null!) + { + var lyric = new Lyric(); + if (cultureInfo == null) + return lyric; + + lyric.Translates.Add(cultureInfo, translate); + return lyric; + } } diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapStageInfoTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapStageInfoTest.cs index a345cbaa1..fb1d46105 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapStageInfoTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/Checks/CheckBeatmapStageInfoTest.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Checks; -public class CheckBeatmapStageInfoTest : BeatmapPropertyCheckTest +public class CheckBeatmapStageInfoTest : BeatmapPropertyCheckTest { [Test] public void TestCheckNoElement() @@ -63,11 +63,11 @@ public void TestCheckMappingItemNotExist() AssertNotOk(getContext(beatmap)); } - public class TestCheckBeatmapStageInfo : CheckBeatmapStageInfo + public class CheckBeatmapStageInfo : CheckBeatmapStageInfo { protected override string Description => "Checks for testing the shared logic"; - public TestCheckBeatmapStageInfo() + public CheckBeatmapStageInfo() { // Note that we only test the lyric layout category. RegisterCategory(x => x.StyleCategory, 0);