Fix drawables are added multiple times in a test scene

This commit is contained in:
ekrctb 2020-12-02 18:06:14 +09:00
parent 1a6b8e022c
commit 5936a8ffb4
1 changed files with 13 additions and 8 deletions

View File

@ -12,13 +12,14 @@ namespace osu.Game.Rulesets.Catch.Tests
{
public class TestSceneFruitRandomness : OsuTestScene
{
[Test]
public void TestFruitRandomness()
{
Bindable<int> randomSeed = new Bindable<int>();
private readonly Bindable<int> randomSeed = new Bindable<int>();
private readonly TestDrawableFruit drawableFruit;
private readonly TestDrawableBanana drawableBanana;
var drawableFruit = new TestDrawableFruit(new Fruit());
var drawableBanana = new TestDrawableBanana(new Banana());
public TestSceneFruitRandomness()
{
drawableFruit = new TestDrawableFruit(new Fruit());
drawableBanana = new TestDrawableBanana(new Banana());
drawableFruit.RandomSeed.BindTo(randomSeed);
drawableBanana.RandomSeed.BindTo(randomSeed);
@ -26,6 +27,12 @@ public void TestFruitRandomness()
Add(new TestDrawableCatchHitObjectSpecimen(drawableFruit) { X = -200 });
Add(new TestDrawableCatchHitObjectSpecimen(drawableBanana));
AddSliderStep("random seed", 0, 100, 0, x => randomSeed.Value = x);
}
[Test]
public void TestFruitRandomness()
{
float fruitRotation = 0;
float bananaRotation = 0;
float bananaScale = 0;
@ -70,8 +77,6 @@ public void TestFruitRandomness()
});
AddAssert("random seed is changed", () => randomSeed.Value == 1000);
AddSliderStep("random seed", 0, 100, 0, x => randomSeed.Value = x);
}
private class TestDrawableFruit : DrawableFruit