mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 07:02:55 +08:00
Add test coverage
This commit is contained in:
parent
eb38bc4b4c
commit
8eb1076fd7
@ -69,6 +69,42 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestImportThenDeleteFromStream()
|
||||
{
|
||||
// unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(ImportBeatmapTest)))
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = LoadOsuIntoHost(host);
|
||||
|
||||
var tempPath = TestResources.GetTestBeatmapForImport();
|
||||
|
||||
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||
|
||||
BeatmapSetInfo importedSet;
|
||||
|
||||
using (var stream = File.OpenRead(tempPath))
|
||||
{
|
||||
importedSet = await manager.Import(new ImportTask(stream, Path.GetFileName(tempPath)));
|
||||
ensureLoaded(osu);
|
||||
}
|
||||
|
||||
Assert.IsTrue(File.Exists(tempPath), "Stream source file somehow went missing");
|
||||
File.Delete(tempPath);
|
||||
|
||||
var imported = manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
|
||||
|
||||
deleteBeatmapSet(imported, osu);
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestImportThenImport()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user