mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:20:04 +08:00
Add test coverage of fail scenario
This commit is contained in:
parent
c0c197501e
commit
a9c59eed02
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
@ -44,6 +43,36 @@ namespace osu.Game.Tests.Editing
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestApplyThenUndoThenApplySameChange()
|
||||
{
|
||||
var (handler, beatmap) = createChangeHandler();
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
string originalHash = handler.CurrentStateHash;
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
string hash = handler.CurrentStateHash;
|
||||
|
||||
// save a save without making any changes
|
||||
handler.RestoreState(-1);
|
||||
|
||||
Assert.That(originalHash, Is.EqualTo(handler.CurrentStateHash));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
Assert.That(hash, Is.EqualTo(handler.CurrentStateHash));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSaveSameStateDoesNotSave()
|
||||
{
|
||||
@ -139,7 +168,7 @@ namespace osu.Game.Tests.Editing
|
||||
|
||||
private void addArbitraryChange(EditorBeatmap beatmap)
|
||||
{
|
||||
beatmap.Add(new HitCircle { StartTime = RNG.Next(0, 100000) });
|
||||
beatmap.Add(new HitCircle { StartTime = 2760 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user