wabbajack/Wabbajack.Test/MO2Tests.cs

65 lines
2.6 KiB
C#
Raw Normal View History

2020-03-27 03:33:24 +00:00
using System.IO;
using System.Threading.Tasks;
using Wabbajack.Common;
using Wabbajack.Lib;
2020-03-27 03:33:24 +00:00
using Xunit;
namespace Wabbajack.Test
{
public class MO2Tests
{
#region CheckValidInstallPath
2020-03-27 03:33:24 +00:00
[Fact]
public async Task CheckValidInstallPath_Empty()
{
await using var tempDir = await TempFolder.Create();
2020-03-27 03:33:24 +00:00
Assert.True(MO2Installer.CheckValidInstallPath(tempDir.Dir, downloadFolder: null).Succeeded);
}
2020-03-27 03:33:24 +00:00
[Fact]
public async Task CheckValidInstallPath_DoesNotExist()
{
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
public async Task CheckValidInstallPath_HasModlist()
{
await using var tempDir = await TempFolder.Create();
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
public async Task CheckValidInstallPath_ProperOverwrite()
{
await using var tempDir = await TempFolder.Create();
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
public async Task CheckValidInstallPath_ImproperOverwrite()
{
await using var tempDir = await TempFolder.Create();
await tempDir.Dir.DeleteDirectory();
2020-03-27 03:33:24 +00:00
tempDir.Dir.CreateDirectory();
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
public async Task CheckValidInstallPath_OverwriteFilesInDownloads()
{
await using var tempDir = await TempFolder.Create();
2020-03-27 03:33:24 +00:00
var downloadsFolder = tempDir.Dir.Combine("downloads");
downloadsFolder.CreateDirectory();
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);
}
#endregion
}
}