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
1 changed files with 13 additions and 12 deletions

View File

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