wabbajack/Wabbajack.Test/MO2Tests.cs

64 lines
2.3 KiB
C#
Raw Normal View History

2020-03-27 03:33:24 +00:00
using System.IO;
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 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);
}
2020-03-27 03:33:24 +00:00
[Fact]
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
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);
}
2020-03-27 03:33:24 +00:00
[Fact]
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);
}
#endregion
}
}