mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 08:27:49 +08:00
Add test coverage of Judged
state
This commit is contained in:
parent
3f8dfc7cb0
commit
e21dc56fcb
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
@ -80,7 +81,9 @@ namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
TestLifetimeEntry entry = null;
|
||||
AddStep("Create entry", () => entry = new TestLifetimeEntry(new HitObject()) { LifetimeStart = 1 });
|
||||
assertJudged(() => entry, false);
|
||||
AddStep("ApplyDefaults", () => entry.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()));
|
||||
assertJudged(() => entry, false);
|
||||
AddAssert("Lifetime is updated", () => entry.LifetimeStart == -TestLifetimeEntry.INITIAL_LIFETIME_OFFSET);
|
||||
|
||||
TestDrawableHitObject dho = null;
|
||||
@ -91,6 +94,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
});
|
||||
AddStep("ApplyDefaults", () => entry.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()));
|
||||
AddAssert("Lifetime is correct", () => dho.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY && entry.LifetimeStart == TestDrawableHitObject.LIFETIME_ON_APPLY);
|
||||
assertJudged(() => entry, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -138,6 +142,29 @@ namespace osu.Game.Tests.Gameplay
|
||||
AddAssert("DHO state is correct", () => dho.State.Value == ArmedState.Miss);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestJudgedStateThroughLifetime()
|
||||
{
|
||||
TestDrawableHitObject dho = null;
|
||||
HitObjectLifetimeEntry lifetimeEntry = null;
|
||||
|
||||
AddStep("Create lifetime entry", () => lifetimeEntry = new HitObjectLifetimeEntry(new HitObject { StartTime = Time.Current }));
|
||||
|
||||
assertJudged(() => lifetimeEntry, false);
|
||||
|
||||
AddStep("Create DHO and apply entry", () =>
|
||||
{
|
||||
Child = dho = new TestDrawableHitObject();
|
||||
dho.Apply(lifetimeEntry);
|
||||
});
|
||||
|
||||
assertJudged(() => lifetimeEntry, false);
|
||||
|
||||
AddStep("Apply result", () => dho.MissForcefully());
|
||||
|
||||
assertJudged(() => lifetimeEntry, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestResultSetBeforeLoadComplete()
|
||||
{
|
||||
@ -154,15 +181,20 @@ namespace osu.Game.Tests.Gameplay
|
||||
}
|
||||
};
|
||||
});
|
||||
assertJudged(() => lifetimeEntry, true);
|
||||
AddStep("Create DHO and apply entry", () =>
|
||||
{
|
||||
dho = new TestDrawableHitObject();
|
||||
dho.Apply(lifetimeEntry);
|
||||
Child = dho;
|
||||
});
|
||||
assertJudged(() => lifetimeEntry, true);
|
||||
AddAssert("DHO state is correct", () => dho.State.Value, () => Is.EqualTo(ArmedState.Hit));
|
||||
}
|
||||
|
||||
private void assertJudged(Func<HitObjectLifetimeEntry> entry, bool val) =>
|
||||
AddAssert(val ? "Is judged" : "Not judged", () => entry().Judged, () => Is.EqualTo(val));
|
||||
|
||||
private partial class TestDrawableHitObject : DrawableHitObject
|
||||
{
|
||||
public const double INITIAL_LIFETIME_OFFSET = 100;
|
||||
|
Loading…
Reference in New Issue
Block a user