Update TestSceneLeadIn to use new assert style

This commit is contained in:
Dean Herbert 2022-08-18 16:32:43 +09:00
parent bcc153f738
commit 728cd96508

View File

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