1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 03:52:57 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs

96 lines
2.8 KiB
C#
Raw Normal View History

2019-06-11 19:58:46 +08:00
// 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.
2019-06-19 22:55:36 +08:00
using NUnit.Framework;
2019-06-11 19:58:46 +08:00
using osu.Game.Beatmaps;
using osu.Game.Overlays.BeatmapSet;
namespace osu.Game.Tests.Visual.Online
{
2019-06-19 22:55:36 +08:00
[TestFixture]
2019-06-27 10:40:22 +08:00
public class TestSceneBeatmapAvailability : OsuTestScene
2019-06-11 19:58:46 +08:00
{
2019-06-27 10:40:22 +08:00
private readonly BeatmapAvailability container;
2019-06-19 22:55:36 +08:00
2019-06-27 10:40:22 +08:00
public TestSceneBeatmapAvailability()
2019-06-11 19:58:46 +08:00
{
2019-06-27 10:40:22 +08:00
Add(container = new BeatmapAvailability());
2019-06-19 22:55:36 +08:00
}
2019-06-11 19:58:46 +08:00
2019-06-19 22:55:36 +08:00
[Test]
public void TestUndownloadableWithLink()
{
AddStep("set undownloadable beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo
{
OnlineInfo = new BeatmapSetOnlineInfo
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = true,
ExternalLink = @"https://osu.ppy.sh",
},
},
});
visiblityAssert(true);
}
2019-06-11 19:58:46 +08:00
2019-06-19 22:55:36 +08:00
[Test]
public void TestUndownloadableNoLink()
{
AddStep("set undownloadable beatmapset without link", () => container.BeatmapSet = new BeatmapSetInfo
2019-06-11 19:58:46 +08:00
{
OnlineInfo = new BeatmapSetOnlineInfo
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = true,
},
},
});
2019-06-19 22:55:36 +08:00
visiblityAssert(true);
}
[Test]
public void TestPartsRemovedWithLink()
{
AddStep("set parts-removed beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo
2019-06-11 19:58:46 +08:00
{
OnlineInfo = new BeatmapSetOnlineInfo
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = false,
2019-06-19 22:55:36 +08:00
ExternalLink = @"https://osu.ppy.sh",
2019-06-11 19:58:46 +08:00
},
},
});
2019-06-19 22:55:36 +08:00
visiblityAssert(true);
}
[Test]
public void TestNormal()
{
2019-06-11 19:58:46 +08:00
AddStep("set normal beatmapset", () => container.BeatmapSet = new BeatmapSetInfo
{
2019-06-19 22:55:36 +08:00
OnlineInfo = new BeatmapSetOnlineInfo
{
Availability = new BeatmapSetOnlineAvailability
{
DownloadDisabled = false,
},
},
2019-06-11 19:58:46 +08:00
});
2019-06-19 22:55:36 +08:00
visiblityAssert(false);
}
private void visiblityAssert(bool shown)
{
AddAssert($"is container {(shown ? "visible" : "hidden")}", () => container.Alpha == (shown ? 1 : 0));
2019-06-11 19:58:46 +08:00
}
}
}