diff --git a/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs b/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs index 50af2cf..e5f4d41 100644 --- a/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs +++ b/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs @@ -181,7 +181,15 @@ public class DownloadHelperTest 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 files = [ @@ -217,7 +225,15 @@ public class DownloadHelperTest 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 files = [ diff --git a/server/RdtClient.Service.Test/Helpers/OSHelper.cs b/server/RdtClient.Service.Test/Helpers/OSHelper.cs new file mode 100644 index 0000000..2a99f74 --- /dev/null +++ b/server/RdtClient.Service.Test/Helpers/OSHelper.cs @@ -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); +} diff --git a/server/RdtClient.Service.Test/Services/TorrentsTest.cs b/server/RdtClient.Service.Test/Services/TorrentsTest.cs index 1b2b5ab..6fe1689 100644 --- a/server/RdtClient.Service.Test/Services/TorrentsTest.cs +++ b/server/RdtClient.Service.Test/Services/TorrentsTest.cs @@ -9,6 +9,7 @@ using RdtClient.Data.Enums; using RdtClient.Data.Models.Data; using RdtClient.Data.Models.Internal; using RdtClient.Service.Services; +using RdtClient.Service.Test.Helpers; using RdtClient.Service.Wrappers; 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)); mocks.DownloadsMock.Setup(d => d.GetForTorrent(torrent.TorrentId)).ReturnsAsync(downloads); - var downloadPath = $"{settings.DownloadClient.DownloadPath}/{torrent.Category}"; - var torrentPath = $"{downloadPath}/{torrent.RdName}"; - var filePath = $"{torrentPath}/{downloads[0].FileName}"; + String downloadPath; + String torrentPath; + 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 {