2020-03-27 03:33:24 +00:00
|
|
|
|
using System.IO;
|
2020-03-28 13:33:39 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-12-21 02:18:36 +00:00
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Wabbajack.Lib;
|
2020-03-27 03:33:24 +00:00
|
|
|
|
using Xunit;
|
2019-12-21 02:18:36 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Test
|
|
|
|
|
{
|
|
|
|
|
public class MO2Tests
|
|
|
|
|
{
|
|
|
|
|
#region CheckValidInstallPath
|
2020-03-27 03:33:24 +00:00
|
|
|
|
[Fact]
|
2020-03-28 13:33:39 +00:00
|
|
|
|
public async Task CheckValidInstallPath_Empty()
|
2019-12-21 02:18:36 +00:00
|
|
|
|
{
|
2020-04-28 04:03:57 +00:00
|
|
|
|
await using var tempDir = await TempFolder.Create();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
Assert.True(MO2Installer.CheckValidInstallPath(tempDir.Dir, downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 03:33:24 +00:00
|
|
|
|
[Fact]
|
2020-03-28 13:33:39 +00:00
|
|
|
|
public async Task CheckValidInstallPath_DoesNotExist()
|
2019-12-21 02:18:36 +00:00
|
|
|
|
{
|
2020-04-28 04:03:57 +00:00
|
|
|
|
await using var tempDir = await TempFolder.Create();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
Assert.True(MO2Installer.CheckValidInstallPath(tempDir.Dir.Combine("Subfolder"), downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 03:33:24 +00:00
|
|
|
|
[Fact]
|
2020-03-28 13:33:39 +00:00
|
|
|
|
public async Task CheckValidInstallPath_HasModlist()
|
2019-12-21 02:18:36 +00:00
|
|
|
|
{
|
2020-04-28 04:03:57 +00:00
|
|
|
|
await using var tempDir = await TempFolder.Create();
|
2020-05-25 17:34:25 +00:00
|
|
|
|
await using var mo2 = await tempDir.Dir.Combine("ModOrganizer.exe").Create();
|
|
|
|
|
await using var molist = await tempDir.Dir.Combine(((RelativePath)"modlist")).WithExtension(Consts.ModListExtension).Create();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
Assert.False(MO2Installer.CheckValidInstallPath(tempDir.Dir, downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 03:33:24 +00:00
|
|
|
|
[Fact]
|
2020-03-28 13:33:39 +00:00
|
|
|
|
public async Task CheckValidInstallPath_ProperOverwrite()
|
2019-12-21 02:18:36 +00:00
|
|
|
|
{
|
2020-04-28 04:03:57 +00:00
|
|
|
|
await using var tempDir = await TempFolder.Create();
|
2020-05-25 17:34:25 +00:00
|
|
|
|
await using var tmp = await tempDir.Dir.Combine(Consts.ModOrganizer2Exe).Create();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
Assert.True(MO2Installer.CheckValidInstallPath(tempDir.Dir, downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 03:33:24 +00:00
|
|
|
|
[Fact]
|
2020-03-28 13:33:39 +00:00
|
|
|
|
public async Task CheckValidInstallPath_ImproperOverwrite()
|
2019-12-21 02:18:36 +00:00
|
|
|
|
{
|
2020-04-28 04:03:57 +00:00
|
|
|
|
await using var tempDir = await TempFolder.Create();
|
2020-03-28 13:33:39 +00:00
|
|
|
|
await tempDir.Dir.DeleteDirectory();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
tempDir.Dir.CreateDirectory();
|
2020-05-25 17:34:25 +00:00
|
|
|
|
await using var tmp = await tempDir.Dir.Combine($"someFile.txt").Create();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
Assert.False(MO2Installer.CheckValidInstallPath(tempDir.Dir, downloadFolder: null).Succeeded);
|
2019-12-22 01:30:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 03:33:24 +00:00
|
|
|
|
[Fact]
|
2020-03-28 13:33:39 +00:00
|
|
|
|
public async Task CheckValidInstallPath_OverwriteFilesInDownloads()
|
2019-12-22 01:30:01 +00:00
|
|
|
|
{
|
2020-04-28 04:03:57 +00:00
|
|
|
|
await using var tempDir = await TempFolder.Create();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
var downloadsFolder = tempDir.Dir.Combine("downloads");
|
|
|
|
|
downloadsFolder.CreateDirectory();
|
2020-05-25 17:34:25 +00:00
|
|
|
|
await using var tmp = await tempDir.Dir.Combine($"downloads/someFile.txt").Create();
|
2020-03-27 03:33:24 +00:00
|
|
|
|
Assert.True(MO2Installer.CheckValidInstallPath(tempDir.Dir, downloadFolder: downloadsFolder).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|