1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Update TestSceneLeadIn to use new assert style

This commit is contained in:
Dean Herbert 2022-08-18 16:32:43 +09:00
parent fa167b1d12
commit 2eba8650ca

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
@ -19,7 +17,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneLeadIn : RateAdjustedBeatmapTestScene
{
private LeadInPlayer player;
private LeadInPlayer player = null!;
private const double lenience_ms = 10;
@ -36,11 +34,7 @@ namespace osu.Game.Tests.Visual.Gameplay
BeatmapInfo = { AudioLeadIn = leadIn }
});
AddStep("check first frame time", () =>
{
Assert.That(player.FirstFrameClockTime, Is.Not.Null);
Assert.That(player.FirstFrameClockTime.Value, Is.EqualTo(expectedStartTime).Within(lenience_ms));
});
checkFirstFrameTime(expectedStartTime);
}
[TestCase(1000, 0)]
@ -59,11 +53,7 @@ namespace osu.Game.Tests.Visual.Gameplay
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), storyboard);
AddStep("check first frame time", () =>
{
Assert.That(player.FirstFrameClockTime, Is.Not.Null);
Assert.That(player.FirstFrameClockTime.Value, Is.EqualTo(expectedStartTime).Within(lenience_ms));
});
checkFirstFrameTime(expectedStartTime);
}
[TestCase(1000, 0, false)]
@ -97,14 +87,13 @@ namespace osu.Game.Tests.Visual.Gameplay
loadPlayerWithBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), storyboard);
AddStep("check first frame time", () =>
{
Assert.That(player.FirstFrameClockTime, Is.Not.Null);
Assert.That(player.FirstFrameClockTime.Value, Is.EqualTo(expectedStartTime).Within(lenience_ms));
});
checkFirstFrameTime(expectedStartTime);
}
private void loadPlayerWithBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
private void checkFirstFrameTime(double expectedStartTime) =>
AddAssert("check first frame time", () => player.FirstFrameClockTime, () => Is.EqualTo(expectedStartTime).Within(lenience_ms));
private void loadPlayerWithBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
{
AddStep("create player", () =>
{
@ -126,12 +115,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new GameplayClockContainer GameplayClockContainer => base.GameplayClockContainer;
public double GameplayStartTime => DrawableRuleset.GameplayStartTime;
public double FirstHitObjectTime => DrawableRuleset.Objects.First().StartTime;
public double GameplayClockTime => GameplayClockContainer.CurrentTime;
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();