1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 10:43:04 +08:00

Use new CleanRun host class in import tests

This commit is contained in:
Dean Herbert 2020-09-17 16:12:30 +09:00
parent 835c8d74b7
commit 89a2f20922

View File

@ -4,6 +4,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using NUnit.Framework; using NUnit.Framework;
@ -22,7 +23,7 @@ namespace osu.Game.Tests.NonVisual
[Test] [Test]
public void TestDefaultDirectory() public void TestDefaultDirectory()
{ {
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestDefaultDirectory))) using (var host = new CustomTestHeadlessGameHost())
{ {
try try
{ {
@ -45,7 +46,7 @@ namespace osu.Game.Tests.NonVisual
{ {
string customPath = prepareCustomPath(); string customPath = prepareCustomPath();
using (var host = new CustomTestHeadlessGameHost(nameof(TestCustomDirectory))) using (var host = new CustomTestHeadlessGameHost())
{ {
using (var storageConfig = new StorageConfigManager(host.InitialStorage)) using (var storageConfig = new StorageConfigManager(host.InitialStorage))
storageConfig.Set(StorageConfig.FullPath, customPath); storageConfig.Set(StorageConfig.FullPath, customPath);
@ -71,7 +72,7 @@ namespace osu.Game.Tests.NonVisual
{ {
string customPath = prepareCustomPath(); string customPath = prepareCustomPath();
using (var host = new CustomTestHeadlessGameHost(nameof(TestSubDirectoryLookup))) using (var host = new CustomTestHeadlessGameHost())
{ {
using (var storageConfig = new StorageConfigManager(host.InitialStorage)) using (var storageConfig = new StorageConfigManager(host.InitialStorage))
storageConfig.Set(StorageConfig.FullPath, customPath); storageConfig.Set(StorageConfig.FullPath, customPath);
@ -104,7 +105,7 @@ namespace osu.Game.Tests.NonVisual
{ {
string customPath = prepareCustomPath(); string customPath = prepareCustomPath();
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigration))) using (var host = new CustomTestHeadlessGameHost())
{ {
try try
{ {
@ -165,7 +166,7 @@ namespace osu.Game.Tests.NonVisual
string customPath = prepareCustomPath(); string customPath = prepareCustomPath();
string customPath2 = prepareCustomPath("-2"); string customPath2 = prepareCustomPath("-2");
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationBetweenTwoTargets))) using (var host = new CustomTestHeadlessGameHost())
{ {
try try
{ {
@ -194,7 +195,7 @@ namespace osu.Game.Tests.NonVisual
{ {
string customPath = prepareCustomPath(); string customPath = prepareCustomPath();
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationToSameTargetFails))) using (var host = new CustomTestHeadlessGameHost())
{ {
try try
{ {
@ -215,7 +216,7 @@ namespace osu.Game.Tests.NonVisual
{ {
string customPath = prepareCustomPath(); string customPath = prepareCustomPath();
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationToNestedTargetFails))) using (var host = new CustomTestHeadlessGameHost())
{ {
try try
{ {
@ -244,7 +245,7 @@ namespace osu.Game.Tests.NonVisual
{ {
string customPath = prepareCustomPath(); string customPath = prepareCustomPath();
using (HeadlessGameHost host = new CustomTestHeadlessGameHost(nameof(TestMigrationToSeeminglyNestedTarget))) using (var host = new CustomTestHeadlessGameHost())
{ {
try try
{ {
@ -315,14 +316,14 @@ namespace osu.Game.Tests.NonVisual
return path; return path;
} }
public class CustomTestHeadlessGameHost : HeadlessGameHost public class CustomTestHeadlessGameHost : CleanRunHeadlessGameHost
{ {
public Storage InitialStorage { get; } public Storage InitialStorage { get; }
public CustomTestHeadlessGameHost(string name) public CustomTestHeadlessGameHost([CallerMemberName] string callingMethodName = @"")
: base(name) : base(callingMethodName: callingMethodName)
{ {
string defaultStorageLocation = getDefaultLocationFor(name); string defaultStorageLocation = getDefaultLocationFor(callingMethodName);
InitialStorage = new DesktopStorage(defaultStorageLocation, this); InitialStorage = new DesktopStorage(defaultStorageLocation, this);
InitialStorage.DeleteDirectory(string.Empty); InitialStorage.DeleteDirectory(string.Empty);