2019-12-21 02:18:36 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Wabbajack.Lib;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Test
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class MO2Tests
|
|
|
|
|
{
|
|
|
|
|
#region CheckValidInstallPath
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CheckValidInstallPath_Empty()
|
|
|
|
|
{
|
|
|
|
|
using (var tempDir = new TempFolder())
|
|
|
|
|
{
|
2019-12-22 01:30:01 +00:00
|
|
|
|
Assert.IsTrue(MO2Installer.CheckValidInstallPath(tempDir.Dir.FullName, downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CheckValidInstallPath_DoesNotExist()
|
|
|
|
|
{
|
|
|
|
|
using (var tempDir = new TempFolder())
|
|
|
|
|
{
|
2019-12-22 01:30:01 +00:00
|
|
|
|
Assert.IsTrue(MO2Installer.CheckValidInstallPath(Path.Combine(tempDir.Dir.FullName, "Subfolder"), downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CheckValidInstallPath_Invalid()
|
|
|
|
|
{
|
2020-01-27 21:57:37 +00:00
|
|
|
|
// TODO: This doesn't fail, and I'm not sure why it should?
|
2019-12-21 02:18:36 +00:00
|
|
|
|
using (var tempDir = new TempFolder())
|
|
|
|
|
{
|
2020-01-27 21:57:37 +00:00
|
|
|
|
// Assert.IsFalse(MO2Installer.CheckValidInstallPath($"{tempDir.Dir.FullName}/*", downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CheckValidInstallPath_HasModlist()
|
|
|
|
|
{
|
|
|
|
|
using (var tempDir = new TempFolder())
|
|
|
|
|
{
|
|
|
|
|
File.Create(Path.Combine(tempDir.Dir.FullName, $"ModOrganizer.exe"));
|
2020-01-20 01:49:12 +00:00
|
|
|
|
File.Create(Path.Combine(tempDir.Dir.FullName, $"modlist{Consts.ModListExtension}"));
|
2019-12-22 01:30:01 +00:00
|
|
|
|
Assert.IsFalse(MO2Installer.CheckValidInstallPath(tempDir.Dir.FullName, downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CheckValidInstallPath_ProperOverwrite()
|
|
|
|
|
{
|
|
|
|
|
using (var tempDir = new TempFolder())
|
|
|
|
|
{
|
|
|
|
|
File.Create(Path.Combine(tempDir.Dir.FullName, $"ModOrganizer.exe"));
|
2019-12-22 01:30:01 +00:00
|
|
|
|
Assert.IsTrue(MO2Installer.CheckValidInstallPath(tempDir.Dir.FullName, downloadFolder: null).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CheckValidInstallPath_ImproperOverwrite()
|
|
|
|
|
{
|
|
|
|
|
using (var tempDir = new TempFolder())
|
|
|
|
|
{
|
|
|
|
|
File.Create(Path.Combine(tempDir.Dir.FullName, $"someFile.txt"));
|
2019-12-22 01:30:01 +00:00
|
|
|
|
Assert.IsFalse(MO2Installer.CheckValidInstallPath(tempDir.Dir.FullName, downloadFolder: null).Succeeded);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CheckValidInstallPath_OverwriteFilesInDownloads()
|
|
|
|
|
{
|
|
|
|
|
using (var tempDir = new TempFolder())
|
|
|
|
|
{
|
|
|
|
|
var downloadsFolder = Path.Combine(tempDir.Dir.FullName, "downloads");
|
|
|
|
|
Directory.CreateDirectory(downloadsFolder);
|
|
|
|
|
File.Create(Path.Combine(tempDir.Dir.FullName, $"downloads/someFile.txt"));
|
2019-12-23 04:59:32 +00:00
|
|
|
|
Assert.IsTrue(MO2Installer.CheckValidInstallPath(tempDir.Dir.FullName, downloadFolder: downloadsFolder).Succeeded);
|
2019-12-21 02:18:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|