Пример #1
0
        public void CannotGetResponsesWithInvalidKey()
        {
            IApiTranslator API = new TranslateAPI("https://translate.yandex.net");

            API.API_Key = "Key";

            var pars = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("ui", "ru"),
                new KeyValuePair <string, string>("key", API.API_Key)
            };
            string response = API.SendRequest("POST", "/api/v1.5/tr.json/getLangs", pars);
        }
Пример #2
0
        public void CanGetResponsetWithValidKey()
        {
            IApiTranslator API = new TranslateAPI("https://translate.yandex.net");

            API.API_Key = "trnsl.1.1.20170705T051451Z.be2ac132d81993cd.d05ddc65d1cb87498519a919b46278f54265b15c";

            var pars = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("ui", "ru"),
                new KeyValuePair <string, string>("key", API.API_Key)
            };
            string response = API.SendRequest("POST", "/api/v1.5/tr.json/getLangs", pars);

            API.FillLanguages(response);

            Assert.IsTrue(response.Contains("\"dirs\""));
            Assert.IsTrue(response.Contains("\"langs\""));
            Assert.IsNotNull(API.Languages);
        }