Beispiel #1
0
        public async Task TestValidScreenScraperLogin()
        {
            var restClient = new Mock <IRestClient>();

            /*
             * restClient
             *  .Setup(x => x.ExecuteGetAsync(
             *      It.IsAny<IRestRequest>(),
             *      It.IsAny<CancellationToken>()))
             *  .Callback<IRestRequest, Action<IRestResponse, CancellationToken>>((request, callback) =>
             *  {
             *      callback(new RestResponse { StatusCode = HttpStatusCode.OK, Content = "{\n\t\"header\" : {\n\t\t\"APIversion\" : \"2.0\",\n\t\t\"dateTime\" : \"2019-08-07 10:20:53\",\n\t\t\"commandRequested\" : \"https://www.screenscraper.fr/api/ssuserInfos.php?devid=redblueflame&devpassword=tests&softname=tests0.1&output=json&ssid=redblueflame&sspassword=tests\",\n\t\t\"success\": \"true\",\n\t\t\"error\": \"\"\n\t},\n\t\"response\" : {\n\t\t\"ssuser\" : {\n\t\t\t\"id\": \"redblueflame\",\n\t\t\t\"niveau\": \"15\",\n\t\t\t\"contribution\": \"4\",\n\t\t\t\"uploadsysteme\": \"0\",\n\t\t\t\"uploadinfos\": \"78\",\n\t\t\t\"romasso\": \"0\",\n\t\t\t\"uploadmedia\": \"23\",\n\t\t\t\"maxthreads\": \"10\",\n\t\t\t\"maxdownloadspeed\": \"43008\",\n\t\t\t\"requeststoday\": \"\",\n\t\t\t\"maxrequestsperday\": \"\",\n\t\t\t\"visites\": \"31\",\n\t\t\t\"datedernierevisite\": \"2019-08-07 10:02:02\",\n\t\t\t\"favregion\": \"\"\n\t\t\t}\n\t\t}\n\t}" },
             *          CancellationToken.None);
             *  });
             */
            restClient
            .Setup(x => x.ExecuteGetAsync(
                       It.IsAny <IRestRequest>(),
                       It.IsAny <CancellationToken>()))
            .Returns(Task.Run(() =>
            {
                return((IRestResponse) new RestResponse
                {
                    StatusCode = HttpStatusCode.OK,
                    Content =
                        "{\n\t\"header\" : {\n\t\t\"APIversion\" : \"2.0\",\n\t\t\"dateTime\" : \"2019-08-07 10:20:53\",\n\t\t\"commandRequested\" : \"https://www.screenscraper.fr/api/ssuserInfos.php?devid=redblueflame&devpassword=tests&softname=tests0.1&output=json&ssid=redblueflame&sspassword=tests\",\n\t\t\"success\": \"true\",\n\t\t\"error\": \"\"\n\t},\n\t\"response\" : {\n\t\t\"ssuser\" : {\n\t\t\t\"id\": \"redblueflame\",\n\t\t\t\"niveau\": \"15\",\n\t\t\t\"contribution\": \"4\",\n\t\t\t\"uploadsysteme\": \"0\",\n\t\t\t\"uploadinfos\": \"78\",\n\t\t\t\"romasso\": \"0\",\n\t\t\t\"uploadmedia\": \"23\",\n\t\t\t\"maxthreads\": \"10\",\n\t\t\t\"maxdownloadspeed\": \"43008\",\n\t\t\t\"requeststoday\": \"\",\n\t\t\t\"maxrequestsperday\": \"\",\n\t\t\t\"visites\": \"31\",\n\t\t\t\"datedernierevisite\": \"2019-08-07 10:02:02\",\n\t\t\t\"favregion\": \"\"\n\t\t\t}\n\t\t}\n\t}"
                });
            }));
            var api = new ScreenScraperAPI(_config, restClient.Object);

            Assert.IsTrue(await api.Login("test", "test"));
        }
Beispiel #2
0
        public async Task TestInvalidScreenScraperLogin()
        {
            _httpTest.RespondWith(
                "Erreur de login : Vérifier les identifiants utilisateurs !            \n\n\n",
                403
                );
            var api = new ScreenScraperAPI(_config);

            Assert.IsFalse(await api.Login("test", "test"));
        }