Пример #1
0
        public void TestPlexConnection(string ipAddress, int port, string username, string password)
        {
            const Applications selectedApp = Applications.Plex;

            var tester = new EndpointTester(Service);
            var uri    = UrlHelper.ReturnUri(ipAddress, port);

            if (uri == null)
            {
                Clients.All.failed(string.Format("Incorrect IP Address"));
                return;
            }

            try
            {
                var result = tester.TestApplicationConnectivity(selectedApp, string.Empty, uri.ToString(), password, username);
                if (!result)
                {
                    Clients.All.failed(string.Format("Could not connect to {0}", selectedApp));
                    return;
                }

                Clients.All.message(string.Format("Connection to {0} is successful", selectedApp));
            }
            catch (Exception e)
            {
                Clients.All.failed(string.Format("{0}", e.Message));
            }
        }
Пример #2
0
        public void SetUp()
        {
            var mockThirdPartyService = new Mock <IThirdPartyService>();
            var f = new Fixture();

            NzbGetStatus       = f.Create <NzbGetStatus>();
            SonarrSystemStatus = f.Create <SonarrSystemStatus>();
            PlexServers        = f.Create <PlexServers>();
            SabNzbdQueue       = f.Create <SabNzbdQueue>();
            CouchPotatoStatus  = f.Build <CouchPotatoStatus>().With(x => x.success, true).Create();

            mockThirdPartyService.Setup(x => x.GetNzbGetStatus(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(NzbGetStatus);
            mockThirdPartyService.Setup(x => x.GetSonarrSystemStatus(It.IsAny <string>(), It.IsAny <string>())).Returns(SonarrSystemStatus);
            mockThirdPartyService.Setup(x => x.GetPlexServers(It.IsAny <string>())).Returns(PlexServers);
            mockThirdPartyService.Setup(x => x.GetCouchPotatoStatus(It.IsAny <string>(), It.IsAny <string>())).Returns(CouchPotatoStatus);
            mockThirdPartyService.Setup(x => x.GetSabNzbdQueue(It.IsAny <string>(), It.IsAny <string>())).Returns(SabNzbdQueue);


            ThirdPartyServiceMock = mockThirdPartyService;
            Tester = new EndpointTester(ThirdPartyServiceMock.Object);
        }
Пример #3
0
        public void TestNzbGetConnection(string ipAddress, int port, string username, string password)
        {
            Logger.Trace(string.Format("Started TestNzbGetConnection with {0}:{1}, {2}", ipAddress, port, username));
            const Applications selectedApp = Applications.NzbGet;

            var tester = new EndpointTester(Service);

            Logger.Trace("Converting IP Address into URI");
            var uri = UrlHelper.ReturnUri(ipAddress, port);

            if (uri == null)
            {
                Logger.Trace("Conversion failed");
                Clients.All.failed(string.Format("Incorrect IP Address"));
                return;
            }
            Logger.Trace("Conversion success");
            try
            {
                Logger.Trace("Testing application connectivity");
                var result = tester.TestApplicationConnectivity(selectedApp, string.Empty, uri.ToString(), password, username);
                if (!result)
                {
                    Logger.Trace("result False");
                    Clients.All.failed(string.Format("Could not connect to {0}", selectedApp));
                    return;
                }
                Logger.Trace("Connected successfully");
                Clients.All.message(string.Format("Connection to {0} is successful", selectedApp));
            }
            catch (Exception e)
            {
                Logger.Warn(string.Format("Test connection to NZBGet failed: {0}", e.Message));
                Clients.All.failed(string.Format("{0}", e.Message));
            }
        }