diff --git a/osu.Game.Tests/Collections/IO/ImportCollectionsTest.cs b/osu.Game.Tests/Collections/IO/ImportCollectionsTest.cs index 686e053246..d4ec5e897b 100644 --- a/osu.Game.Tests/Collections/IO/ImportCollectionsTest.cs +++ b/osu.Game.Tests/Collections/IO/ImportCollectionsTest.cs @@ -128,8 +128,12 @@ namespace osu.Game.Tests.Collections.IO [Test] public async Task TestSaveAndReload() { - using (HeadlessGameHost host = new CleanRunHeadlessGameHost(bypassCleanup: true)) + string firstRunName; + + using (var host = new CleanRunHeadlessGameHost(bypassCleanup: true)) { + firstRunName = host.Name; + try { var osu = LoadOsuIntoHost(host, true); @@ -150,7 +154,7 @@ namespace osu.Game.Tests.Collections.IO } // Name matches the automatically chosen name from `CleanRunHeadlessGameHost` above, so we end up using the same storage location. - using (HeadlessGameHost host = new TestRunHeadlessGameHost(nameof(TestSaveAndReload))) + using (HeadlessGameHost host = new TestRunHeadlessGameHost(firstRunName)) { try { diff --git a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs index 999994cae0..4bb54f1625 100644 --- a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs +++ b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs @@ -25,7 +25,7 @@ namespace osu.Game.Tests.NonVisual { try { - string defaultStorageLocation = getDefaultLocationFor(nameof(TestDefaultDirectory)); + string defaultStorageLocation = getDefaultLocationFor(host); var osu = LoadOsuIntoHost(host); var storage = osu.Dependencies.Get(); @@ -109,7 +109,7 @@ namespace osu.Game.Tests.NonVisual { try { - string defaultStorageLocation = getDefaultLocationFor(nameof(TestMigration)); + string defaultStorageLocation = getDefaultLocationFor(host); var osu = LoadOsuIntoHost(host); var storage = osu.Dependencies.Get(); @@ -284,9 +284,9 @@ namespace osu.Game.Tests.NonVisual } } - private static string getDefaultLocationFor(string testTypeName) + private static string getDefaultLocationFor(CustomTestHeadlessGameHost host) { - string path = Path.Combine(TestRunHeadlessGameHost.TemporaryTestDirectory, testTypeName); + string path = Path.Combine(TestRunHeadlessGameHost.TemporaryTestDirectory, host.Name); if (Directory.Exists(path)) Directory.Delete(path, true); @@ -315,7 +315,7 @@ namespace osu.Game.Tests.NonVisual public CustomTestHeadlessGameHost([CallerMemberName] string callingMethodName = @"") : base(callingMethodName: callingMethodName) { - string defaultStorageLocation = getDefaultLocationFor(Name); + string defaultStorageLocation = getDefaultLocationFor(this); InitialStorage = new DesktopStorage(defaultStorageLocation, this); InitialStorage.DeleteDirectory(string.Empty); diff --git a/osu.Game/Tests/CleanRunHeadlessGameHost.cs b/osu.Game/Tests/CleanRunHeadlessGameHost.cs index 1c341ea243..2be2f3cd65 100644 --- a/osu.Game/Tests/CleanRunHeadlessGameHost.cs +++ b/osu.Game/Tests/CleanRunHeadlessGameHost.cs @@ -12,6 +12,8 @@ namespace osu.Game.Tests /// public class CleanRunHeadlessGameHost : TestRunHeadlessGameHost { + public new string Name => base.Name; + /// /// Create a new instance. ///