2020-03-27 03:33:24 +00:00
|
|
|
|
using System.IO;
|
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]
|
2019-12-21 02:18:36 +00:00
|
|
|
|
public void CheckValidInstallPath_Empty()
|
|
|
|
|
{
|
2020-03-27 03:33:24 +00:00
|
|
|
|
using var tempDir = new TempFolder();
|
|
|
|
|
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]
|
2019-12-21 02:18:36 +00:00
|
|
|
|
public void CheckValidInstallPath_DoesNotExist()
|
|
|
|
|
{
|
2020-03-27 03:33:24 +00:00
|
|
|
|
using var tempDir = new TempFolder();
|
|
|
|
|
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]
|
2019-12-21 02:18:36 +00:00
|
|
|
|
public void CheckValidInstallPath_HasModlist()
|
|
|
|
|
{
|
2020-03-27 03:33:24 +00:00
|
|
|
|
using var tempDir = new TempFolder();
|
|
|
|
|
using var mo2 = tempDir.Dir.Combine("ModOrganizer.exe").Create();
|
|
|
|
|
using var molist = tempDir.Dir.Combine(((RelativePath)"modlist")).WithExtension(Consts.ModListExtension).Create();
|
|
|
|
|
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]
|
2019-12-21 02:18:36 +00:00
|
|
|
|
public void CheckValidInstallPath_ProperOverwrite()
|
|
|
|
|
{
|
2020-03-27 03:33:24 +00:00
|
|
|
|
using var tempDir = new TempFolder();
|
|
|
|
|
using var tmp = tempDir.Dir.Combine(Consts.ModOrganizer2Exe).Create();
|
|
|
|
|
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]
|
2019-12-21 02:18:36 +00:00
|
|
|
|
public void CheckValidInstallPath_ImproperOverwrite()
|
|
|
|
|
{
|
2020-03-27 03:33:24 +00:00
|
|
|
|
using var tempDir = new TempFolder();
|
|
|
|
|
tempDir.Dir.DeleteDirectory();
|
|
|
|
|
tempDir.Dir.CreateDirectory();
|
|
|
|
|
using var tmp = tempDir.Dir.Combine($"someFile.txt").Create();
|
|
|
|
|
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]
|
2019-12-22 01:30:01 +00:00
|
|
|
|
public void CheckValidInstallPath_OverwriteFilesInDownloads()
|
|
|
|
|
{
|
2020-03-27 03:33:24 +00:00
|
|
|
|
using var tempDir = new TempFolder();
|
|
|
|
|
var downloadsFolder = tempDir.Dir.Combine("downloads");
|
|
|
|
|
downloadsFolder.CreateDirectory();
|
|
|
|
|
using var tmp = tempDir.Dir.Combine($"downloads/someFile.txt").Create();
|
|
|
|
|
Assert.True(MO2Installer.CheckValidInstallPath(tempDir.Dir, downloadFolder: downloadsFolder).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|