fix(tests): Make the test fixtures os independant
This commit is contained in:
parent
8664993ff6
commit
d576ee7f01
3 changed files with 13 additions and 63 deletions
|
|
@ -181,16 +181,7 @@ public class DownloadHelperTest
|
|||
FileName = "file.txt"
|
||||
};
|
||||
|
||||
String fileRelativePath;
|
||||
|
||||
if (OSHelper.IsWindows)
|
||||
{
|
||||
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
|
||||
}
|
||||
var fileRelativePath = Path.Combine("inside", "lots", "of", "subdirectories", "file.txt");
|
||||
|
||||
IList<DebridClientFile> files =
|
||||
[
|
||||
|
|
@ -212,7 +203,7 @@ public class DownloadHelperTest
|
|||
var path = DownloadHelper.GetDownloadPath("/data/downloads", torrent, download, fileSystem);
|
||||
|
||||
// Assert
|
||||
var expectedPath = Path.Combine("/data/downloads", torrent.RdName, fileRelativePath);
|
||||
var expectedPath = Path.Combine("/data/downloads", torrent.RdName, "inside", "lots", "of", "subdirectories", "file.txt");
|
||||
Assert.Equal(expectedPath, path);
|
||||
}
|
||||
|
||||
|
|
@ -226,16 +217,7 @@ public class DownloadHelperTest
|
|||
FileName = "file.txt"
|
||||
};
|
||||
|
||||
String fileRelativePath;
|
||||
|
||||
if (OSHelper.IsWindows)
|
||||
{
|
||||
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
|
||||
}
|
||||
var fileRelativePath = Path.Combine("inside", "lots", "of", "subdirectories", "file.txt");
|
||||
|
||||
IList<DebridClientFile> files =
|
||||
[
|
||||
|
|
@ -255,7 +237,7 @@ public class DownloadHelperTest
|
|||
var path = DownloadHelper.GetDownloadPath(torrent, download);
|
||||
|
||||
// Assert
|
||||
var expectedPath = Path.Combine(torrent.RdName, fileRelativePath);
|
||||
var expectedPath = Path.Combine(torrent.RdName, "inside", "lots", "of", "subdirectories", "file.txt");
|
||||
Assert.Equal(expectedPath, path);
|
||||
}
|
||||
|
||||
|
|
@ -269,16 +251,7 @@ public class DownloadHelperTest
|
|||
FileName = "file.txt"
|
||||
};
|
||||
|
||||
String fileRelativePath;
|
||||
|
||||
if (OSHelper.IsWindows)
|
||||
{
|
||||
fileRelativePath = @"Torrent Name\Saison 1\file.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileRelativePath = "Torrent Name/Saison 1/file.txt";
|
||||
}
|
||||
var fileRelativePath = Path.Combine("Torrent Name", "Saison 1", "file.txt");
|
||||
|
||||
IList<DebridClientFile> files =
|
||||
[
|
||||
|
|
@ -315,16 +288,7 @@ public class DownloadHelperTest
|
|||
FileName = "file.txt"
|
||||
};
|
||||
|
||||
String fileRelativePath;
|
||||
|
||||
if (OSHelper.IsWindows)
|
||||
{
|
||||
fileRelativePath = @"Torrent Name\Saison 1\file.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileRelativePath = "Torrent Name/Saison 1/file.txt";
|
||||
}
|
||||
var fileRelativePath = Path.Combine("Torrent Name", "Saison 1", "file.txt");
|
||||
|
||||
IList<DebridClientFile> files =
|
||||
[
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RdtClient.Service.Test.Helpers;
|
||||
|
||||
public static class OSHelper
|
||||
{
|
||||
public static Boolean IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
}
|
||||
|
|
@ -94,19 +94,13 @@ public class TorrentsTest
|
|||
String torrentPath;
|
||||
String filePath;
|
||||
|
||||
if (OSHelper.IsWindows)
|
||||
{
|
||||
Settings.Get.DownloadClient.DownloadPath = settings.DownloadClient.DownloadPath = @"C:\Downloads";
|
||||
downloadPath = @$"{settings.DownloadClient.DownloadPath}\{torrent.Category}";
|
||||
torrentPath = @$"{downloadPath}\{torrent.RdName}";
|
||||
filePath = @$"{torrentPath}\{downloads[0].FileName}";
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}";
|
||||
torrentPath = $"{downloadPath}/{torrent.RdName}";
|
||||
filePath = $"{torrentPath}/{downloads[0].FileName}";
|
||||
}
|
||||
var category = torrent.Category!;
|
||||
var torrentName = torrent.RdName!;
|
||||
var fileName = downloads[0].FileName!;
|
||||
|
||||
downloadPath = Path.Combine(settings.DownloadClient.DownloadPath, category);
|
||||
torrentPath = Path.Combine(downloadPath, torrentName);
|
||||
filePath = Path.Combine(torrentPath, fileName);
|
||||
|
||||
var fileSystemMock = new MockFileSystem(new Dictionary<String, MockFileData>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue