Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            _wordsService   = new WordsService();
            _yandexServices = new YandexServices();

            _textBox.PreviewMouseDoubleClick += TextBox_PreviewMouseDoubleClick;
        }
Ejemplo n.º 2
0
        public MainViewModel(YandexServices yandexServices)
        {
            _yandexServices = yandexServices ??
                              throw new ArgumentNullException(nameof(yandexServices));

            Langs = new List <string>()
            {
                "с русского на английский", "с английского на русский"
            };
        }
        public async Task GetDictionaryAsync_WhenEngInput_ThenRusOutput()
        {
            string         input    = "thought";
            string         output   = "мысль";
            YandexServices services = new YandexServices();
            MainViewModel  sut      = new MainViewModel(services);

            sut.Input        = input;
            sut.SelectedLang = 1;
            await sut.GetDictionaryAsync();

            Assert.IsTrue(sut.Output.Contains(output));
        }
        public async Task GetTransationAsync_WhenEngInput_ThenRusOutput()
        {
            string         input    = "measure twice cut once";
            string         output   = "семь раз отмерь один раз отрежь";
            YandexServices services = new YandexServices();
            MainViewModel  sut      = new MainViewModel(services);

            sut.Input        = input;
            sut.SelectedLang = 1;
            await sut.GetTransationAsync();

            Assert.IsTrue(sut.Output.Contains(output));
        }
        public async Task GetTransationAsync_WhenRusInput_ThenEngOutput()
        {
            string         input    = "семь раз отмерь один раз отрежь";
            string         output   = "measure twice cut once\r\n";
            YandexServices services = new YandexServices();
            MainViewModel  sut      = new MainViewModel(services);

            sut.Input        = input;
            sut.SelectedLang = 0;
            await sut.GetTransationAsync();

            Assert.AreEqual(output, sut.Output);
        }
        public async Task GetDictionaryAnswerAsyncTest()
        {
            var            ru  = "мысль";
            var            eng = "thought";
            YandexServices sut = new YandexServices();

            YandexServices.TranslationDirection direction
                = YandexServices.TranslationDirection.RuEng;

            YandexAnswer answer = await sut.GetDictionaryAnswerAsync(ru, direction);

            Assert.AreEqual("OK", answer.Code);
            Assert.IsTrue(answer.Text.Contains(eng));
        }
        public async Task GetTranslateAnswerAsyncTest()
        {
            var            ru  = "семь раз отмерь один раз отрежь";
            var            eng = "measure twice cut once\r\n";
            YandexServices sut = new YandexServices();

            YandexServices.TranslationDirection direction
                = YandexServices.TranslationDirection.RuEng;

            YandexAnswer answer = await sut.GetTranslateAnswerAsync(ru, direction);

            Assert.AreEqual("OK", answer.Code);
            Assert.AreEqual(eng, answer.Text);
        }