Added test helper to make sure tests pass on Windows.

This commit is contained in:
Roger Far 2026-02-21 15:33:12 -07:00
parent 7c94528847
commit b7df2bfb15
3 changed files with 43 additions and 5 deletions

View file

@ -181,7 +181,15 @@ public class DownloadHelperTest
FileName = "file.txt" FileName = "file.txt"
}; };
var fileRelativePath = "inside/lots/of/subdirectories/file.txt"; String fileRelativePath;
if (OSHelper.IsLinux)
{
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
}
else
{
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
}
IList<DebridClientFile> files = IList<DebridClientFile> files =
[ [
@ -217,7 +225,15 @@ public class DownloadHelperTest
FileName = "file.txt" FileName = "file.txt"
}; };
var fileRelativePath = "inside/lots/of/subdirectories/file.txt"; String fileRelativePath;
if (OSHelper.IsLinux)
{
fileRelativePath = "inside/lots/of/subdirectories/file.txt";
}
else
{
fileRelativePath = @"inside\lots\of\subdirectories\file.txt";
}
IList<DebridClientFile> files = IList<DebridClientFile> files =
[ [

View file

@ -0,0 +1,8 @@
using System.Runtime.InteropServices;
namespace RdtClient.Service.Test.Helpers;
public static class OSHelper
{
public static Boolean IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
}

View file

@ -9,6 +9,7 @@ using RdtClient.Data.Enums;
using RdtClient.Data.Models.Data; using RdtClient.Data.Models.Data;
using RdtClient.Data.Models.Internal; using RdtClient.Data.Models.Internal;
using RdtClient.Service.Services; using RdtClient.Service.Services;
using RdtClient.Service.Test.Helpers;
using RdtClient.Service.Wrappers; using RdtClient.Service.Wrappers;
using TorrentsService = RdtClient.Service.Services.Torrents; using TorrentsService = RdtClient.Service.Services.Torrents;
@ -88,9 +89,22 @@ public class TorrentsTest
mocks.TorrentDataMock.Setup(t => t.GetById(torrent.TorrentId)).Returns(Task.FromResult<Torrent?>(torrent)); mocks.TorrentDataMock.Setup(t => t.GetById(torrent.TorrentId)).Returns(Task.FromResult<Torrent?>(torrent));
mocks.DownloadsMock.Setup(d => d.GetForTorrent(torrent.TorrentId)).ReturnsAsync(downloads); mocks.DownloadsMock.Setup(d => d.GetForTorrent(torrent.TorrentId)).ReturnsAsync(downloads);
var downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}"; String downloadPath;
var torrentPath = $"{downloadPath}/{torrent.RdName}"; String torrentPath;
var filePath = $"{torrentPath}/{downloads[0].FileName}"; String filePath;
if (OSHelper.IsLinux)
{
downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}";
torrentPath = $"{downloadPath}/{torrent.RdName}";
filePath = $"{torrentPath}/{downloads[0].FileName}";
}
else
{
Settings.Get.DownloadClient.DownloadPath = settings.DownloadClient.DownloadPath = @"C:\Downloads";
downloadPath = @$"{settings.DownloadClient.DownloadPath}\{torrent.Category}";
torrentPath = @$"{downloadPath}\{torrent.RdName}";
filePath = @$"{torrentPath}\{downloads[0].FileName}";
}
var fileSystemMock = new MockFileSystem(new Dictionary<String, MockFileData> var fileSystemMock = new MockFileSystem(new Dictionary<String, MockFileData>
{ {