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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
            });
        }
Пример #7
0
        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);
        }
Пример #8
0
        public override DownloadClientInfo GetStatus()
        {
            var status = new DownloadClientInfo
            {
                IsLocalhost = true
            };

            return(status);
        }
Пример #9
0
        public override DownloadClientInfo GetStatus()
        {
            var status = new DownloadClientInfo
            {
                IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
            };

            return(status);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
            });
        }
Пример #12
0
        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);
        }