Ejemplo n.º 1
0
        public async Task CheckBadKey()
        {
            YandexTranslateSdk wrapper = new YandexTranslateSdk();

            wrapper.ApiKey = "KeyNotExists";
            await Assert.ThrowsAsync <YandexTranslateException>(() => wrapper.GetLanguages());
        }
Ejemplo n.º 2
0
        public async Task CheckNullKey()
        {
            YandexTranslateSdk wrapper = new YandexTranslateSdk();

            wrapper.ApiKey = null;
            await Assert.ThrowsAsync <YandexTranslateException>(() => wrapper.GetLanguages());
        }
Ejemplo n.º 3
0
        public async Task CheckNullKey()
        {
            YandexTranslateSdk wrapper = new YandexTranslateSdk();

            wrapper.ApiKey = null;
            List <string> languages = await wrapper.GetLanguages();
        }
Ejemplo n.º 4
0
        public async Task CheckBadKey()
        {
            YandexTranslateSdk wrapper = new YandexTranslateSdk();

            wrapper.ApiKey = "KeyNotExists";
            List <string> languages = await wrapper.GetLanguages();
        }
Ejemplo n.º 5
0
        public async Task GetLanguagesJsonTest()
        {
            YandexTranslateSdk wrapper = new YandexTranslateSdk();

            wrapper.ApiKey = _apiKey;
            wrapper.IsJson = true;
            List <string> languages = await wrapper.GetLanguages();

            Assert.NotEqual(languages, null);
            Assert.True(languages.Contains("en"));
            Assert.True(languages.Contains("ru"));
        }
        public async Task <ActionResult> GetLanguages(TranslateViewModel model)
        {
            if (string.IsNullOrEmpty(model.Key))
            {
                throw new Exception("Empty API Key");
            }
            YandexTranslateSdk wrapper = new YandexTranslateSdk();

            wrapper.ApiKey  = model.Key;
            model.Languages = await wrapper.GetLanguages();

            TempData["Languages"] = model.Languages;
            return(View("Index", model));
        }
 private async void LoadLanguages()
 {
     if (apiKey != null)
     {
         wrapper.ApiKey = apiKey;
         List <string> languages;
         try
         {
             languages = await wrapper.GetLanguages();
         }
         catch (YandexTranslateException ex)
         {
             MessageBox.Show(ex.Message);
             return;
         }
         languagesCombo.ItemsSource = languagesCombo2.ItemsSource = languages;
         if (languagesCombo.Items.Count > 0)
         {
             languagesCombo.SelectedIndex  = 0;
             languagesCombo2.SelectedIndex = 0;
         }
     }
 }
 public virtual async Task <IEnumerable <string> > GetLanguagesAsync()
 {
     return(await _yandexTranslateSdk.GetLanguages());
 }