mirror of
https://github.com/ppy/osu
synced 2025-01-22 22:03:12 +00:00
Update test assertions in line with new state saving logic
This commit is contained in:
parent
17ca26ebee
commit
b0131db1dc
@ -21,18 +21,23 @@ namespace osu.Game.Tests.Editing
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSaveRestoreState()
|
||||
public void TestSaveRestoreStateUsingTransaction()
|
||||
{
|
||||
var (handler, beatmap) = createChangeHandler();
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
handler.BeginChange();
|
||||
|
||||
// Initial state will be saved on BeginChange
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.EndChange();
|
||||
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
@ -41,7 +46,35 @@ namespace osu.Game.Tests.Editing
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.True);
|
||||
|
||||
Assert.That(stateChangedFired, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSaveRestoreState()
|
||||
{
|
||||
var (handler, beatmap) = createChangeHandler();
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
// Save initial state
|
||||
handler.SaveState();
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
handler.RestoreState(-1);
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.True);
|
||||
|
||||
Assert.That(stateChangedFired, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -52,6 +85,10 @@ namespace osu.Game.Tests.Editing
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
// Save initial state
|
||||
handler.SaveState();
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
string originalHash = handler.CurrentStateHash;
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
@ -59,7 +96,7 @@ namespace osu.Game.Tests.Editing
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
|
||||
string hash = handler.CurrentStateHash;
|
||||
|
||||
@ -67,7 +104,7 @@ namespace osu.Game.Tests.Editing
|
||||
handler.RestoreState(-1);
|
||||
|
||||
Assert.That(originalHash, Is.EqualTo(handler.CurrentStateHash));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(3));
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
@ -82,12 +119,16 @@ namespace osu.Game.Tests.Editing
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
|
||||
// Save initial state
|
||||
handler.SaveState();
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.True);
|
||||
Assert.That(handler.CanRedo.Value, Is.False);
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
|
||||
string hash = handler.CurrentStateHash;
|
||||
|
||||
@ -95,7 +136,7 @@ namespace osu.Game.Tests.Editing
|
||||
handler.SaveState();
|
||||
|
||||
Assert.That(hash, Is.EqualTo(handler.CurrentStateHash));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
|
||||
handler.RestoreState(-1);
|
||||
|
||||
@ -104,7 +145,7 @@ namespace osu.Game.Tests.Editing
|
||||
// we should only be able to restore once even though we saved twice.
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
Assert.That(handler.CanRedo.Value, Is.True);
|
||||
Assert.That(stateChangedFired, Is.EqualTo(2));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -112,11 +153,15 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
var (handler, beatmap) = createChangeHandler();
|
||||
|
||||
// Save initial state
|
||||
handler.SaveState();
|
||||
Assert.That(stateChangedFired, Is.EqualTo(1));
|
||||
|
||||
Assert.That(handler.CanUndo.Value, Is.False);
|
||||
|
||||
for (int i = 0; i < EditorChangeHandler.MAX_SAVED_STATES; i++)
|
||||
{
|
||||
Assert.That(stateChangedFired, Is.EqualTo(i));
|
||||
Assert.That(stateChangedFired, Is.EqualTo(i + 1));
|
||||
|
||||
addArbitraryChange(beatmap);
|
||||
handler.SaveState();
|
||||
|
Loading…
Reference in New Issue
Block a user