mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 21:02:54 +08:00
Extract assert step addition out of assertion method
This commit is contained in:
parent
21ca9c8431
commit
71da960000
@ -43,26 +43,24 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void TestEmptyDefaultBeatmapSkinFallsBack()
|
||||
{
|
||||
CreateSkinTest(DefaultLegacySkin.Info, () => new TestWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)).Skin);
|
||||
AssertComponentsFromExpectedSource(SkinnableTarget.MainHUDComponents, () => skinManager.CurrentSkin.Value);
|
||||
AddAssert("hud from default legacy skin", () => AssertComponentsFromExpectedSource(SkinnableTarget.MainHUDComponents, skinManager.CurrentSkin.Value));
|
||||
}
|
||||
|
||||
protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> beatmapSkin)
|
||||
protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> getBeatmapSkin)
|
||||
{
|
||||
CreateTest(() =>
|
||||
{
|
||||
AddStep("setup skins", () =>
|
||||
{
|
||||
skinManager.CurrentSkinInfo.Value = gameCurrentSkin;
|
||||
currentBeatmapSkin = beatmapSkin();
|
||||
currentBeatmapSkin = getBeatmapSkin();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected void AssertComponentsFromExpectedSource(SkinnableTarget target, Func<ISkin> expectedSource)
|
||||
protected bool AssertComponentsFromExpectedSource(SkinnableTarget target, ISkin expectedSource)
|
||||
{
|
||||
AddAssert($"{target} from {expectedSource.GetType().Name}", () =>
|
||||
{
|
||||
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource().GetDrawableComponent(new SkinnableTargetComponent(target));
|
||||
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new SkinnableTargetComponent(target));
|
||||
|
||||
Add(expectedComponentsContainer);
|
||||
expectedComponentsContainer?.UpdateSubTree();
|
||||
@ -73,7 +71,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
.ChildrenOfType<SkinnableTargetComponentsContainer>().Single().CreateSkinnableInfo();
|
||||
|
||||
return almostEqual(actualInfo, expectedInfo, 2f);
|
||||
});
|
||||
|
||||
static bool almostEqual(SkinnableInfo info, SkinnableInfo other, float positionTolerance) =>
|
||||
other != null
|
||||
|
Loading…
Reference in New Issue
Block a user