mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Add tests for custom matching logic
This commit is contained in:
@ -4,8 +4,10 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Filter;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Select.Carousel;
|
using osu.Game.Screens.Select.Carousel;
|
||||||
|
using osu.Game.Screens.Select.Filter;
|
||||||
|
|
||||||
namespace osu.Game.Tests.NonVisual.Filtering
|
namespace osu.Game.Tests.NonVisual.Filtering
|
||||||
{
|
{
|
||||||
@ -214,5 +216,31 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
|
|
||||||
Assert.AreEqual(filtered, carouselItem.Filtered.Value);
|
Assert.AreEqual(filtered, carouselItem.Filtered.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCustomRulesetCriteria([Values(null, true, false)] bool? matchCustomCriteria)
|
||||||
|
{
|
||||||
|
var beatmap = getExampleBeatmap();
|
||||||
|
|
||||||
|
var customCriteria = matchCustomCriteria is bool match ? new CustomCriteria(match) : null;
|
||||||
|
var criteria = new FilterCriteria { RulesetCriteria = customCriteria };
|
||||||
|
var carouselItem = new CarouselBeatmap(beatmap);
|
||||||
|
carouselItem.Filter(criteria);
|
||||||
|
|
||||||
|
Assert.AreEqual(matchCustomCriteria == false, carouselItem.Filtered.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CustomCriteria : IRulesetFilterCriteria
|
||||||
|
{
|
||||||
|
private readonly bool match;
|
||||||
|
|
||||||
|
public CustomCriteria(bool shouldMatch)
|
||||||
|
{
|
||||||
|
match = shouldMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Matches(BeatmapInfo beatmap) => match;
|
||||||
|
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value) => false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user