diff --git a/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs b/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs index 90ba064..0ad55a9 100644 --- a/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs +++ b/server/RdtClient.Service.Test/Helpers/DownloadHelperTest.cs @@ -181,16 +181,7 @@ public class DownloadHelperTest FileName = "file.txt" }; - String fileRelativePath; - - if (OSHelper.IsLinux) - { - 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 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.IsLinux) - { - 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 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.IsLinux) - { - 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 files = [ @@ -315,16 +288,7 @@ public class DownloadHelperTest FileName = "file.txt" }; - String fileRelativePath; - - if (OSHelper.IsLinux) - { - 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 files = [ diff --git a/server/RdtClient.Service.Test/Helpers/OSHelper.cs b/server/RdtClient.Service.Test/Helpers/OSHelper.cs deleted file mode 100644 index 2a99f74..0000000 --- a/server/RdtClient.Service.Test/Helpers/OSHelper.cs +++ /dev/null @@ -1,8 +0,0 @@ -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 7018d59..c3672e9 100644 --- a/server/RdtClient.Service.Test/Services/TorrentsTest.cs +++ b/server/RdtClient.Service.Test/Services/TorrentsTest.cs @@ -94,19 +94,13 @@ public class TorrentsTest 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 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 {