Skip to content

Commit 80fa5d1

Browse files
committed
Don't access test instance dir without copying
1 parent 9732fba commit 80fa5d1

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Tests/Core/GameInstanceManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ public void FindAndRegisterDefaultInstances_WithMockedSteam_FindsInstances()
362362
{
363363
// Arrange
364364
using (var config = new FakeConfiguration(new List<Tuple<string, string, string>>(), null, null))
365+
using (var nonSteamGameDir = TemporaryDirectory.CopiedFromDir(TestData.good_ksp_dir()))
365366
using (var dir = new TemporarySteamDirectory(
366367
new (string acfFileName, int appId, string appName)[]
367368
{
@@ -375,7 +376,7 @@ public void FindAndRegisterDefaultInstances_WithMockedSteam_FindsInstances()
375376
new (string name, string absPath)[]
376377
{
377378
(name: "Test Instance",
378-
absPath: Path.GetFullPath(TestData.good_ksp_dir())),
379+
absPath: nonSteamGameDir),
379380
}))
380381
{
381382
var steamLib = new SteamLibrary(dir);

Tests/Core/IO/SteamLibraryTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public sealed class SteamLibraryTests
1616
public void Constructor_WithValidLibrary_Works()
1717
{
1818
// Arrange
19+
using (var nonSteamGameDir = TemporaryDirectory.CopiedFromDir(TestData.good_ksp_dir()))
1920
using (var dir = new TemporarySteamDirectory(
2021
new (string acfFileName, int appId, string appName)[]
2122
{
@@ -29,7 +30,7 @@ public void Constructor_WithValidLibrary_Works()
2930
new (string name, string absPath)[]
3031
{
3132
(name: "Test Instance",
32-
absPath: Path.GetFullPath(TestData.good_ksp_dir())),
33+
absPath: nonSteamGameDir),
3334
}))
3435
{
3536
// Act
@@ -50,6 +51,7 @@ public void Constructor_WithValidLibrary_Works()
5051
public void Constructor_WithCorruptedLibrary_Works()
5152
{
5253
// Arrange
54+
using (var nonSteamGameDir = TemporaryDirectory.CopiedFromDir(TestData.good_ksp_dir()))
5355
using (var dir = new TemporarySteamDirectory(
5456
new (string acfFileName, int appId, string appName)[]
5557
{
@@ -63,7 +65,7 @@ public void Constructor_WithCorruptedLibrary_Works()
6365
new (string name, string absPath)[]
6466
{
6567
(name: "Test Instance",
66-
absPath: Path.GetFullPath(TestData.good_ksp_dir())),
68+
absPath: nonSteamGameDir),
6769
(name: "Empty StartDir",
6870
absPath: ""),
6971
}))

Tests/Data/TemporaryDirectory.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.IO;
33

4+
using CKAN;
5+
46
namespace Tests.Data
57
{
68
public class TemporaryDirectory : IDisposable
@@ -21,6 +23,14 @@ public TemporaryDirectory()
2123
{
2224
}
2325

26+
public static TemporaryDirectory CopiedFromDir(string fromPath)
27+
{
28+
var dir = new TemporaryDirectory();
29+
Utilities.CopyDirectory(fromPath, dir,
30+
Array.Empty<string>(), Array.Empty<string>());
31+
return dir;
32+
}
33+
2434
public void Dispose()
2535
{
2636
Directory.Delete(true);

0 commit comments

Comments
 (0)