Ejemplo n.º 1
0
        public void TranslateSpeedTest()
        {
            bool success = false;

            string[] test =
            {
                "안녕하세요",
                "테스트",
                "안녕하세요",
                "테스트",
                "안녕하세요",
                "테스트",
                "안녕하세요",
                "테스트",
                "안녕하세요",
                "테스트",
                "안녕하세요",
                "테스트",
                "안녕하세요",
            };
            using PapagoBrowser papagoBrowser = new PapagoBrowser(true);

            for (int i = 0; i < test.Length; i++)
            {
                var result = papagoBrowser.Translate(test[i], LanguageType.Auto, LanguageType.English);
                if (result.Success)
                {
                    success = true;
                    Trace.WriteLine(result.Result);
                }
            }
            Assert.IsTrue(success);
        }
Ejemplo n.º 2
0
        private void TextChangeTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            string       source     = string.Empty;
            LanguageType sourceType = LanguageType.Auto;
            LanguageType targetType = LanguageType.English;

            Dispatcher.Invoke(() =>
            {
                source     = Source.Text;
                sourceType = SourceLanguageTypes[SourceType.SelectedIndex];
                targetType = TargetLanguageTypes[TargetType.SelectedIndex];
            });

            lock (LockObj)
            {
                var result = Papago.Translate(source, sourceType, targetType).Result;

                Dispatcher.Invoke(() => { Target.Text = result; });
            }
        }
Ejemplo n.º 3
0
        public void TranslateLanguageTypeTest()
        {
            bool success = false;

            using PapagoBrowser papagoBrowser = new PapagoBrowser(true);

            foreach (var item in Enum.GetNames(typeof(LanguageType)))
            {
                var result = papagoBrowser.Translate("안녕하세요", LanguageType.Korean, (LanguageType)Enum.Parse(typeof(LanguageType), item));
                Trace.WriteLine($"{item,-20}   {result.Result}");

                if (result.Success)
                {
                    success = true;
                }
            }

            Assert.IsTrue(success);
        }