Skip to content

Commit

Permalink
Fix the invalid test name.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed May 22, 2024
1 parent fddc282 commit f6a03cf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ public void TestHaveLyricButNoLanguage()
}

[Test]
public void TestHaveLyricAndLanguage()
public void TestEveryLyricContainsTranslate()
{
var translateLanguages = new List<CultureInfo> { 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<CultureInfo> { new("Ja-jp") };
Expand All @@ -75,39 +88,30 @@ public void TestHaveLyricAndLanguage()
createLyric(new CultureInfo("Ja-jp"), string.Empty),
});
AssertNotOk<IssueTemplateMissingTranslate>(getContext(beatmap3));
}

[Test]
public void TestCheckMissingPartialTranslate()
{
// some lyric with translate string. (should have issue)
var translateLanguages = new List<CultureInfo> { new("Ja-jp") };
var beatmap4 = createTestingBeatmap(translateLanguages, new[]
{
createLyric(new CultureInfo("Ja-jp"), "translate1"),
createLyric(new CultureInfo("Ja-jp")),
});
AssertNotOk<IssueTemplateMissingPartialTranslate>(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<IssueTemplateContainsNotListedLanguage>(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<CultureInfo>? translateLanguage, IEnumerable<Lyric>? lyrics)
Expand All @@ -126,4 +130,14 @@ private static IBeatmap createTestingBeatmap(List<CultureInfo>? 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Checks;

public class CheckBeatmapStageInfoTest : BeatmapPropertyCheckTest<CheckBeatmapStageInfoTest.TestCheckBeatmapStageInfo>
public class CheckBeatmapStageInfoTest : BeatmapPropertyCheckTest<CheckBeatmapStageInfoTest.CheckBeatmapStageInfo>
{
[Test]
public void TestCheckNoElement()
Expand Down Expand Up @@ -63,11 +63,11 @@ public void TestCheckMappingItemNotExist()
AssertNotOk<IssueTemplateMappingItemNotExist>(getContext(beatmap));
}

public class TestCheckBeatmapStageInfo : CheckBeatmapStageInfo<ClassicStageInfo>
public class CheckBeatmapStageInfo : CheckBeatmapStageInfo<ClassicStageInfo>
{
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);
Expand Down

0 comments on commit f6a03cf

Please sign in to comment.