From 3d638abc52d39a33b64388610a006f007f413100 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 15 Jun 2022 08:24:18 +0300 Subject: [PATCH] Fix test files stream not disposed after creation --- .../Database/LegacyBeatmapImporterTest.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs b/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs index 145ba2c730..2af46374fe 100644 --- a/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs +++ b/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs @@ -26,19 +26,19 @@ namespace osu.Game.Tests.Database // normal beatmap folder var beatmap1 = songsStorage.GetStorageForDirectory("beatmap1"); - beatmap1.CreateFileSafely("beatmap.osu"); + createFile(beatmap1, "beatmap.osu"); // songs subdirectory var subdirectory = songsStorage.GetStorageForDirectory("subdirectory"); - subdirectory.CreateFileSafely(subdirectory.GetFullPath(Path.Combine("beatmap2", "beatmap.osu"), true)); - subdirectory.CreateFileSafely(subdirectory.GetFullPath(Path.Combine("beatmap3", "beatmap.osu"), true)); - subdirectory.CreateFileSafely(subdirectory.GetFullPath(Path.Combine("sub-subdirectory", "beatmap4", "beatmap.osu"), true)); + createFile(subdirectory, Path.Combine("beatmap2", "beatmap.osu")); + createFile(subdirectory, Path.Combine("beatmap3", "beatmap.osu")); + createFile(subdirectory, Path.Combine("sub-subdirectory", "beatmap4", "beatmap.osu")); // songs subdirectory with system file var subdirectory2 = songsStorage.GetStorageForDirectory("subdirectory2"); - subdirectory2.CreateFileSafely(subdirectory2.GetFullPath(".DS_Store")); - subdirectory2.CreateFileSafely(subdirectory2.GetFullPath(Path.Combine("beatmap5", "beatmap.osu"), true)); - subdirectory2.CreateFileSafely(subdirectory2.GetFullPath(Path.Combine("beatmap6", "beatmap.osu"), true)); + createFile(subdirectory2, ".DS_Store"); + createFile(subdirectory2, Path.Combine("beatmap5", "beatmap.osu")); + createFile(subdirectory2, Path.Combine("beatmap6", "beatmap.osu")); // empty songs subdirectory songsStorage.GetStorageForDirectory("subdirectory3"); @@ -52,6 +52,12 @@ namespace osu.Game.Tests.Database Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory2", "beatmap5")))); Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory2", "beatmap6")))); } + + static void createFile(Storage storage, string path) + { + using (var stream = storage.CreateFileSafely(path)) + stream.WriteByte(0); + } } private class TestLegacyBeatmapImporter : LegacyBeatmapImporter