public void Setup() { _clientStatus = new DownloadClientInfo { IsLocalhost = true, OutputRootFolders = new List <OsPath> { new OsPath(_downloadRootPath) } }; _downloadClient = Mocker.GetMock <IDownloadClient>(); _downloadClient.Setup(s => s.Definition) .Returns(new DownloadClientDefinition { Name = "Test" }); _downloadClient.Setup(s => s.GetStatus()) .Returns(_clientStatus); Mocker.GetMock <IProvideDownloadClient>() .Setup(s => s.GetDownloadClients()) .Returns(new IDownloadClient[] { _downloadClient.Object }); Mocker.GetMock <IDiskProvider>() .Setup(x => x.FolderExists(It.IsAny <string>())) .Returns(true); Mocker.GetMock <IDiskProvider>() .Setup(x => x.FolderWritable(It.IsAny <string>())) .Returns(true); }
public override DownloadClientInfo GetStatus() { var config = _proxy.GetConfig(Settings); var destDir = new OsPath(config.GetValueOrDefault("download_location") as string); if (config.GetValueOrDefault("move_completed", false).ToString() == "True") { destDir = new OsPath(config.GetValueOrDefault("move_completed_path") as string); } var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; if (!destDir.IsEmpty) { status.OutputRootFolders = new List <OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }; } return(status); }
public override DownloadClientInfo GetStatus() { var config = _proxy.GetConfig(Settings); var categories = GetCategories(config).ToArray(); var category = categories.FirstOrDefault(v => v.Name == Settings.MusicCategory); if (category == null) { category = categories.FirstOrDefault(v => v.Name == "*"); } var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; if (category != null) { status.OutputRootFolders = new List <OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, category.FullPath) }; } return(status); }
public override DownloadClientInfo GetStatus() { var config = _proxy.GetConfig(Settings); var label = _proxy.GetLabelOptions(Settings); OsPath destDir; if (label != null && label.ApplyMoveCompleted && label.MoveCompleted) { // if label exists and a label completed path exists and is enabled use it instead of global destDir = new OsPath(label.MoveCompletedPath); } else if (config.GetValueOrDefault("move_completed", false).ToString() == "True") { destDir = new OsPath(config.GetValueOrDefault("move_completed_path") as string); } else { destDir = new OsPath(config.GetValueOrDefault("download_location") as string); } var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; if (!destDir.IsEmpty) { status.OutputRootFolders = new List <OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }; } return(status); }
public override DownloadClientInfo GetStatus() { var config = _proxy.GetConfig(Settings); OsPath destDir = new OsPath(null); if (config.GetValueOrDefault("dir_active_download_flag") == "true") { destDir = new OsPath(config.GetValueOrDefault("dir_active_download")); } if (config.GetValueOrDefault("dir_completed_download_flag") == "true") { destDir = new OsPath(config.GetValueOrDefault("dir_completed_download")); if (config.GetValueOrDefault("dir_add_label") == "true") { destDir = destDir + Settings.MusicCategory; } } var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; if (!destDir.IsEmpty) { status.OutputRootFolders = new List <OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }; } return(status); }
public void Setup() { _downloadItem = new DownloadClientItem { DownloadClientInfo = new DownloadClientItemClientInfo { Protocol = DownloadProtocol.Usenet, Id = 1, Name = "Test" }, DownloadId = "TestId", OutputPath = new OsPath(_downloadItemPath) }; _clientStatus = new DownloadClientInfo { IsLocalhost = true, OutputRootFolders = new List <OsPath> { new OsPath(_downloadRootPath) } }; _downloadClient = Mocker.GetMock <IDownloadClient>(); _downloadClient.Setup(s => s.Definition) .Returns(new DownloadClientDefinition { Name = "Test" }); _downloadClient.Setup(s => s.GetItems()) .Returns(new List <DownloadClientItem> { _downloadItem }); _downloadClient.Setup(s => s.GetStatus()) .Returns(_clientStatus); Mocker.GetMock <IProvideDownloadClient>() .Setup(s => s.GetDownloadClients()) .Returns(new IDownloadClient[] { _downloadClient.Object }); Mocker.GetMock <IConfigService>() .Setup(s => s.EnableCompletedDownloadHandling) .Returns(true); Mocker.GetMock <IDiskProvider>() .Setup(x => x.FolderExists(It.IsAny <string>())) .Returns((string path) => { Ensure.That(path, () => path).IsValidPath(); return(false); }); Mocker.GetMock <IDiskProvider>() .Setup(x => x.FileExists(It.IsAny <string>())) .Returns((string path) => { Ensure.That(path, () => path).IsValidPath(); return(false); }); }
public override DownloadClientInfo GetStatus() { var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; var client = CreateClient(); var request = new RestRequest("/api/getConfig"); var response = client.Execute(request); var pyloadConfig = JObject.Parse(response.Content); var generalConfigArray = (JArray)pyloadConfig["general"]["items"]; var generalConfigItems = generalConfigArray.Select(g => JsonConvert.DeserializeObject <PyloadConfigItem>(g.ToString())); var folderItem = generalConfigItems.FirstOrDefault(f => f.Type == "folder"); if (folderItem != null) { status.OutputRootFolders = new List <OsPath>(); status.OutputRootFolders.Add(_remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(folderItem.Value))); ////status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, folderItem.Value) }; } return(status); }
public override DownloadClientInfo GetStatus() { var status = new DownloadClientInfo { IsLocalhost = true }; return(status); }
public override DownloadClientInfo GetStatus() { var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; return(status); }
public override DownloadClientInfo GetStatus() { // XXX: This function's correctness has not been considered var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; return(status); }
public void Setup() { downloadItem = new DownloadClientItem { DownloadClient = "Test", DownloadId = "TestId", OutputPath = new OsPath(downloadItemPath) }; clientStatus = new DownloadClientInfo { IsLocalhost = true, OutputRootFolders = new List <OsPath> { new OsPath(downloadRootPath) } }; downloadClient = Mocker.GetMock <IDownloadClient>(); downloadClient.Setup(s => s.Definition) .Returns(new DownloadClientDefinition { Name = "Test" }); downloadClient.Setup(s => s.GetItems()) .Returns(new List <DownloadClientItem> { downloadItem }); downloadClient.Setup(s => s.GetStatus()) .Returns(clientStatus); Mocker.GetMock <IProvideDownloadClient>() .Setup(s => s.GetDownloadClients()) .Returns(new IDownloadClient[] { downloadClient.Object }); Mocker.GetMock <IDiskProvider>() .Setup(x => x.FolderExists(It.IsAny <string>())) .Returns((string path) => { Ensure.That(path, () => path).IsValidPath(); return(false); }); Mocker.GetMock <IDiskProvider>() .Setup(x => x.FileExists(It.IsAny <string>())) .Returns((string path) => { Ensure.That(path, () => path).IsValidPath(); return(false); }); }
public override DownloadClientInfo GetStatus() { var config = _proxy.GetConfig(Settings); var destDir = new OsPath(config.GetValueOrDefault("bittorrent.defaultSavePath") as string); var status = new DownloadClientInfo { IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" }; if (!destDir.IsEmpty) { status.OutputRootFolders = new List <OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }; } return(status); }