1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 10:22:54 +08:00

Simplify tests

This commit is contained in:
Bartłomiej Dach 2024-03-28 10:05:26 +01:00
parent 60c93d2c6d
commit a9cbabf711
No known key found for this signature in database
2 changed files with 133 additions and 240 deletions

View File

@ -1,6 +1,7 @@
// 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.
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -20,93 +21,78 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
[Test] [Test]
public void TestReverseSelectionTwoFruits() public void TestReverseSelectionTwoFruits()
{ {
float fruit1OldX = default; CatchHitObject[] objects = null!;
float fruit2OldX = default; bool[] newCombos = null!;
addObjects([ addObjects([
new Fruit new Fruit
{ {
StartTime = 200, StartTime = 200,
X = fruit1OldX = 0, X = 0,
}, },
new Fruit new Fruit
{ {
StartTime = 400, StartTime = 400,
X = fruit2OldX = 20, X = 20,
} }
]); ]);
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
selectEverything(); selectEverything();
reverseSelection(); reverseSelection();
AddAssert("fruit1 is at fruit2's X", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(0).EffectiveX, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(fruit2OldX)
);
AddAssert("fruit2 is at fruit1's X",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(1).EffectiveX,
() => Is.EqualTo(fruit1OldX)
);
AddAssert("fruit2 is not a new combo",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(1).NewCombo,
() => Is.EqualTo(false)
);
} }
[Test] [Test]
public void TestReverseSelectionThreeFruits() public void TestReverseSelectionThreeFruits()
{ {
float fruit1OldX = default; CatchHitObject[] objects = null!;
float fruit2OldX = default; bool[] newCombos = null!;
float fruit3OldX = default;
addObjects([ addObjects([
new Fruit new Fruit
{ {
StartTime = 200, StartTime = 200,
X = fruit1OldX = 0, X = 0,
}, },
new Fruit new Fruit
{ {
StartTime = 400, StartTime = 400,
X = fruit2OldX = 20, X = 20,
}, },
new Fruit new Fruit
{ {
StartTime = 600, StartTime = 600,
X = fruit3OldX = 40, X = 40,
} }
]); ]);
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
selectEverything(); selectEverything();
reverseSelection(); reverseSelection();
AddAssert("fruit1 is at fruit3's X", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(0).EffectiveX, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(fruit3OldX)
);
AddAssert("fruit2's X is unchanged",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(1).EffectiveX,
() => Is.EqualTo(fruit2OldX)
);
AddAssert("fruit3's is at fruit1's X",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(2).EffectiveX,
() => Is.EqualTo(fruit1OldX)
);
AddAssert("fruit3 is not a new combo",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(2).NewCombo,
() => Is.EqualTo(false)
);
} }
[Test] [Test]
public void TestReverseSelectionFruitAndJuiceStream() public void TestReverseSelectionFruitAndJuiceStream()
{ {
CatchHitObject[] objects = null!;
bool[] newCombos = null!;
addObjects([ addObjects([
new Fruit new Fruit
{ {
@ -128,28 +114,25 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
} }
]); ]);
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
selectEverything(); selectEverything();
reverseSelection(); reverseSelection();
AddAssert("First element is juice stream", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.First().GetType(), AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(typeof(JuiceStream))
);
AddAssert("Last element is fruit",
() => EditorBeatmap.HitObjects.Last().GetType(),
() => Is.EqualTo(typeof(Fruit))
);
AddAssert("Fruit is not new combo",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(0).NewCombo,
() => Is.EqualTo(false)
);
} }
[Test] [Test]
public void TestReverseSelectionTwoFruitsAndJuiceStream() public void TestReverseSelectionTwoFruitsAndJuiceStream()
{ {
CatchHitObject[] objects = null!;
bool[] newCombos = null!;
addObjects([ addObjects([
new Fruit new Fruit
{ {
@ -176,122 +159,79 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
} }
]); ]);
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
selectEverything(); selectEverything();
reverseSelection(); reverseSelection();
AddAssert("First element is juice stream", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.First().GetType(), AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(typeof(JuiceStream))
);
AddAssert("Middle element is Fruit",
() => EditorBeatmap.HitObjects.ElementAt(1).GetType(),
() => Is.EqualTo(typeof(Fruit))
);
AddAssert("Last element is Fruit",
() => EditorBeatmap.HitObjects.Last().GetType(),
() => Is.EqualTo(typeof(Fruit))
);
AddAssert("Last fruit is not new combo",
() => EditorBeatmap.HitObjects.OfType<Fruit>().Last().NewCombo,
() => Is.EqualTo(false)
);
} }
[Test] [Test]
public void TestReverseSelectionTwoCombos() public void TestReverseSelectionTwoCombos()
{ {
float fruit1OldX = default; CatchHitObject[] objects = null!;
float fruit2OldX = default; bool[] newCombos = null!;
float fruit3OldX = default;
float fruit4OldX = default;
float fruit5OldX = default;
float fruit6OldX = default;
addObjects([ addObjects([
new Fruit new Fruit
{ {
StartTime = 200, StartTime = 200,
X = fruit1OldX = 0, X = 0,
}, },
new Fruit new Fruit
{ {
StartTime = 400, StartTime = 400,
X = fruit2OldX = 20, X = 20,
}, },
new Fruit new Fruit
{ {
StartTime = 600, StartTime = 600,
X = fruit3OldX = 40, X = 40,
}, },
new Fruit new Fruit
{ {
StartTime = 800, StartTime = 800,
NewCombo = true, NewCombo = true,
X = fruit4OldX = 60, X = 60,
}, },
new Fruit new Fruit
{ {
StartTime = 1000, StartTime = 1000,
X = fruit5OldX = 80, X = 80,
}, },
new Fruit new Fruit
{ {
StartTime = 1200, StartTime = 1200,
X = fruit6OldX = 100, X = 100,
} }
]); ]);
AddStep("store objects & new combo data", () =>
{
objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
});
selectEverything(); selectEverything();
reverseSelection(); reverseSelection();
AddAssert("fruit1 is at fruit6 position", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(0).EffectiveX, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(fruit6OldX)
);
AddAssert("fruit2 is at fruit5 position",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(1).EffectiveX,
() => Is.EqualTo(fruit5OldX)
);
AddAssert("fruit3 is at fruit4 position",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(2).EffectiveX,
() => Is.EqualTo(fruit4OldX)
);
AddAssert("fruit4 is at fruit3 position",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(3).EffectiveX,
() => Is.EqualTo(fruit3OldX)
);
AddAssert("fruit5 is at fruit2 position",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(4).EffectiveX,
() => Is.EqualTo(fruit2OldX)
);
AddAssert("fruit6 is at fruit1 position",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(5).EffectiveX,
() => Is.EqualTo(fruit1OldX)
);
AddAssert("fruit1 is new combo",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(0).NewCombo,
() => Is.EqualTo(true)
);
AddAssert("fruit4 is new combo",
() => EditorBeatmap.HitObjects.OfType<Fruit>().ElementAt(3).NewCombo,
() => Is.EqualTo(true)
);
} }
private void addObjects(CatchHitObject[] hitObjects) => AddStep("Add objects", () => EditorBeatmap.AddRange(hitObjects)); private void addObjects(CatchHitObject[] hitObjects) => AddStep("Add objects", () => EditorBeatmap.AddRange(hitObjects));
private IEnumerable<CatchHitObject> getObjects() => EditorBeatmap.HitObjects.OfType<CatchHitObject>();
private IEnumerable<bool> getObjectNewCombos() => getObjects().Select(ho => ho.NewCombo);
private void selectEverything() private void selectEverything()
{ {
AddStep("Select everything", () => AddStep("Select everything", () =>

View File

@ -1,6 +1,7 @@
// 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.
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -20,30 +21,33 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
[Test] [Test]
public void TestReverseSelectionTwoCircles() public void TestReverseSelectionTwoCircles()
{ {
Vector2 circle1OldPosition = default; OsuHitObject[] objects = null!;
Vector2 circle2OldPosition = default; bool[] newCombos = null!;
AddStep("Add circles", () => AddStep("Add circles", () =>
{ {
var circle1 = new HitCircle var circle1 = new HitCircle
{ {
StartTime = 0, StartTime = 0,
Position = circle1OldPosition = new Vector2(208, 240) Position = new Vector2(208, 240)
}; };
var circle2 = new HitCircle var circle2 = new HitCircle
{ {
StartTime = 200, StartTime = 200,
Position = circle2OldPosition = new Vector2(256, 144) Position = new Vector2(256, 144)
}; };
EditorBeatmap.AddRange([circle1, circle2]); EditorBeatmap.AddRange([circle1, circle2]);
}); });
AddStep("Select circles", () => AddStep("store objects & new combo data", () =>
{ {
EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
}); });
AddStep("Select circles", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
AddStep("Reverse selection", () => AddStep("Reverse selection", () =>
{ {
InputManager.PressKey(Key.LControl); InputManager.PressKey(Key.LControl);
@ -51,55 +55,45 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
InputManager.ReleaseKey(Key.LControl); InputManager.ReleaseKey(Key.LControl);
}); });
AddAssert("circle1 is at circle2 position", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(0).Position, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(circle2OldPosition)
);
AddAssert("circle2 is at circle1 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(1).Position,
() => Is.EqualTo(circle1OldPosition)
);
AddAssert("circle2 is not a new combo",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(1).NewCombo,
() => Is.EqualTo(false)
);
} }
[Test] [Test]
public void TestReverseSelectionThreeCircles() public void TestReverseSelectionThreeCircles()
{ {
Vector2 circle1OldPosition = default; OsuHitObject[] objects = null!;
Vector2 circle2OldPosition = default; bool[] newCombos = null!;
Vector2 circle3OldPosition = default;
AddStep("Add circles", () => AddStep("Add circles", () =>
{ {
var circle1 = new HitCircle var circle1 = new HitCircle
{ {
StartTime = 0, StartTime = 0,
Position = circle1OldPosition = new Vector2(208, 240) Position = new Vector2(208, 240)
}; };
var circle2 = new HitCircle var circle2 = new HitCircle
{ {
StartTime = 200, StartTime = 200,
Position = circle2OldPosition = new Vector2(256, 144) Position = new Vector2(256, 144)
}; };
var circle3 = new HitCircle var circle3 = new HitCircle
{ {
StartTime = 400, StartTime = 400,
Position = circle3OldPosition = new Vector2(304, 240) Position = new Vector2(304, 240)
}; };
EditorBeatmap.AddRange([circle1, circle2, circle3]); EditorBeatmap.AddRange([circle1, circle2, circle3]);
}); });
AddStep("Select circles", () => AddStep("store objects & new combo data", () =>
{ {
EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
}); });
AddStep("Select circles", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
AddStep("Reverse selection", () => AddStep("Reverse selection", () =>
{ {
InputManager.PressKey(Key.LControl); InputManager.PressKey(Key.LControl);
@ -107,26 +101,16 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
InputManager.ReleaseKey(Key.LControl); InputManager.ReleaseKey(Key.LControl);
}); });
AddAssert("circle1 is at circle3 position", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(0).Position, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(circle3OldPosition)
);
AddAssert("circle3 is at circle1 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(2).Position,
() => Is.EqualTo(circle1OldPosition)
);
AddAssert("circle3 is not a new combo",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(2).NewCombo,
() => Is.EqualTo(false)
);
} }
[Test] [Test]
public void TestReverseSelectionCircleAndSlider() public void TestReverseSelectionCircleAndSlider()
{ {
Vector2 circleOldPosition = default; OsuHitObject[] objects = null!;
bool[] newCombos = null!;
Vector2 sliderHeadOldPosition = default; Vector2 sliderHeadOldPosition = default;
Vector2 sliderTailOldPosition = default; Vector2 sliderTailOldPosition = default;
@ -135,7 +119,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
var circle = new HitCircle var circle = new HitCircle
{ {
StartTime = 0, StartTime = 0,
Position = circleOldPosition = new Vector2(208, 240) Position = new Vector2(208, 240)
}; };
var slider = new Slider var slider = new Slider
{ {
@ -156,14 +140,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
EditorBeatmap.AddRange([circle, slider]); EditorBeatmap.AddRange([circle, slider]);
}); });
AddStep("Select objects", () => AddStep("store objects & new combo data", () =>
{ {
var circle = (HitCircle)EditorBeatmap.HitObjects[0]; objects = getObjects().ToArray();
var slider = (Slider)EditorBeatmap.HitObjects[1]; newCombos = getObjectNewCombos().ToArray();
EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects);
}); });
AddStep("Select objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
AddStep("Reverse selection", () => AddStep("Reverse selection", () =>
{ {
InputManager.PressKey(Key.LControl); InputManager.PressKey(Key.LControl);
@ -171,10 +155,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
InputManager.ReleaseKey(Key.LControl); InputManager.ReleaseKey(Key.LControl);
}); });
AddAssert("circle is at the same position", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(0).Position, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(circleOldPosition)
);
AddAssert("Slider head is at slider tail", () => AddAssert("Slider head is at slider tail", () =>
Vector2.Distance(EditorBeatmap.HitObjects.OfType<Slider>().ElementAt(0).Position, sliderTailOldPosition) < 1); Vector2.Distance(EditorBeatmap.HitObjects.OfType<Slider>().ElementAt(0).Position, sliderTailOldPosition) < 1);
@ -186,8 +168,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
[Test] [Test]
public void TestReverseSelectionTwoCirclesAndSlider() public void TestReverseSelectionTwoCirclesAndSlider()
{ {
Vector2 circle1OldPosition = default; OsuHitObject[] objects = null!;
Vector2 circle2OldPosition = default; bool[] newCombos = null!;
Vector2 sliderHeadOldPosition = default; Vector2 sliderHeadOldPosition = default;
Vector2 sliderTailOldPosition = default; Vector2 sliderTailOldPosition = default;
@ -197,12 +179,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
var circle1 = new HitCircle var circle1 = new HitCircle
{ {
StartTime = 0, StartTime = 0,
Position = circle1OldPosition = new Vector2(208, 240) Position = new Vector2(208, 240)
}; };
var circle2 = new HitCircle var circle2 = new HitCircle
{ {
StartTime = 200, StartTime = 200,
Position = circle2OldPosition = new Vector2(256, 144) Position = new Vector2(256, 144)
}; };
var slider = new Slider var slider = new Slider
{ {
@ -223,11 +205,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
EditorBeatmap.AddRange([circle1, circle2, slider]); EditorBeatmap.AddRange([circle1, circle2, slider]);
}); });
AddStep("Select objects", () => AddStep("store objects & new combo data", () =>
{ {
EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
}); });
AddStep("Select objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
AddStep("Reverse selection", () => AddStep("Reverse selection", () =>
{ {
InputManager.PressKey(Key.LControl); InputManager.PressKey(Key.LControl);
@ -235,15 +220,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
InputManager.ReleaseKey(Key.LControl); InputManager.ReleaseKey(Key.LControl);
}); });
AddAssert("circle1 is at circle2 position", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(0).Position, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(circle2OldPosition)
);
AddAssert("circle2 is at circle1 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(1).Position,
() => Is.EqualTo(circle1OldPosition)
);
AddAssert("Slider head is at slider tail", () => AddAssert("Slider head is at slider tail", () =>
Vector2.Distance(EditorBeatmap.HitObjects.OfType<Slider>().ElementAt(0).Position, sliderTailOldPosition) < 1); Vector2.Distance(EditorBeatmap.HitObjects.OfType<Slider>().ElementAt(0).Position, sliderTailOldPosition) < 1);
@ -255,57 +233,55 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
[Test] [Test]
public void TestReverseSelectionTwoCombos() public void TestReverseSelectionTwoCombos()
{ {
Vector2 circle1OldPosition = default; OsuHitObject[] objects = null!;
Vector2 circle2OldPosition = default; bool[] newCombos = null!;
Vector2 circle3OldPosition = default;
Vector2 circle4OldPosition = default;
Vector2 circle5OldPosition = default;
Vector2 circle6OldPosition = default;
AddStep("Add circles", () => AddStep("Add circles", () =>
{ {
var circle1 = new HitCircle var circle1 = new HitCircle
{ {
StartTime = 0, StartTime = 0,
Position = circle1OldPosition = new Vector2(216, 240) Position = new Vector2(216, 240)
}; };
var circle2 = new HitCircle var circle2 = new HitCircle
{ {
StartTime = 200, StartTime = 200,
Position = circle2OldPosition = new Vector2(120, 192) Position = new Vector2(120, 192)
}; };
var circle3 = new HitCircle var circle3 = new HitCircle
{ {
StartTime = 400, StartTime = 400,
Position = circle3OldPosition = new Vector2(216, 144) Position = new Vector2(216, 144)
}; };
var circle4 = new HitCircle var circle4 = new HitCircle
{ {
StartTime = 646, StartTime = 646,
NewCombo = true, NewCombo = true,
Position = circle4OldPosition = new Vector2(296, 240) Position = new Vector2(296, 240)
}; };
var circle5 = new HitCircle var circle5 = new HitCircle
{ {
StartTime = 846, StartTime = 846,
Position = circle5OldPosition = new Vector2(392, 162) Position = new Vector2(392, 162)
}; };
var circle6 = new HitCircle var circle6 = new HitCircle
{ {
StartTime = 1046, StartTime = 1046,
Position = circle6OldPosition = new Vector2(296, 144) Position = new Vector2(296, 144)
}; };
EditorBeatmap.AddRange([circle1, circle2, circle3, circle4, circle5, circle6]); EditorBeatmap.AddRange([circle1, circle2, circle3, circle4, circle5, circle6]);
}); });
AddStep("Select circles", () => AddStep("store objects & new combo data", () =>
{ {
EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); objects = getObjects().ToArray();
newCombos = getObjectNewCombos().ToArray();
}); });
AddStep("Select circles", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
AddStep("Reverse selection", () => AddStep("Reverse selection", () =>
{ {
InputManager.PressKey(Key.LControl); InputManager.PressKey(Key.LControl);
@ -313,35 +289,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
InputManager.ReleaseKey(Key.LControl); InputManager.ReleaseKey(Key.LControl);
}); });
AddAssert("circle1 is at circle6 position", AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse()));
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(0).Position, AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos));
() => Is.EqualTo(circle6OldPosition)
);
AddAssert("circle2 is at circle5 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(1).Position,
() => Is.EqualTo(circle5OldPosition)
);
AddAssert("circle3 is at circle4 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(2).Position,
() => Is.EqualTo(circle4OldPosition)
);
AddAssert("circle4 is at circle3 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(3).Position,
() => Is.EqualTo(circle3OldPosition)
);
AddAssert("circle5 is at circle2 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(4).Position,
() => Is.EqualTo(circle2OldPosition)
);
AddAssert("circle6 is at circle1 position",
() => EditorBeatmap.HitObjects.OfType<HitCircle>().ElementAt(5).Position,
() => Is.EqualTo(circle1OldPosition)
);
} }
private IEnumerable<OsuHitObject> getObjects() => EditorBeatmap.HitObjects.OfType<OsuHitObject>();
private IEnumerable<bool> getObjectNewCombos() => getObjects().Select(ho => ho.NewCombo);
} }
} }