public void Detect_Method()
        {
            Assert.Throws <ArgumentNullException>(() => IYandexTranslatorExtensions.Detect(null, "text"));
            Assert.Throws <ArgumentNullException>(() => xmlTranslator.Detect(null));
            Assert.Throws <ArgumentException>(() => xmlTranslator.Detect(string.Empty));

            string language;

            Assert.Throws <ArgumentNullException>(() => IYandexTranslatorExtensions.Detect(null, "text", out language));
            Assert.Throws <ArgumentNullException>(() => xmlTranslator.Detect(null, out language));
            Assert.Throws <ArgumentException>(() => xmlTranslator.Detect(string.Empty, out language));

            Assert.Equal("en", xmlTranslator.Detect("Hello, world"));
            Assert.Equal("ru", xmlTranslator.Detect("Привет, мир"));
            Assert.True(xmlTranslator.Detect("Hello, world", out language));
            Assert.Equal("en", language);
            Assert.True(xmlTranslator.Detect("Привет, мир", out language));
            Assert.Equal("ru", language);

            Assert.Equal("en", jsonTranslator.Detect("Hello, world"));
            Assert.Equal("ru", jsonTranslator.Detect("Привет, мир"));
            Assert.True(jsonTranslator.Detect("Hello, world", out language));
            Assert.Equal("en", language);
            Assert.True(jsonTranslator.Detect("Привет, мир", out language));
            Assert.Equal("ru", language);
        }
        public void TranslationPairs_Method()
        {
            Assert.Throws <ArgumentNullException>(() => IYandexTranslatorExtensions.TranslationPairs(null));

            IEnumerable <ITranslationPair> pairs;

            Assert.Throws <ArgumentNullException>(() => IYandexTranslatorExtensions.TranslationPairs(null, out pairs));


            TestTranslationPairsResult(xmlTranslator.TranslationPairs());
            Assert.True(xmlTranslator.TranslationPairs(out pairs));
            TestTranslationPairsResult(pairs);

            TestTranslationPairsResult(jsonTranslator.TranslationPairs());
            Assert.True(jsonTranslator.TranslationPairs(out pairs));
            TestTranslationPairsResult(pairs);
        }
        public void Translate_Method()
        {
            Assert.Throws <ArgumentNullException>(() => IYandexTranslatorExtensions.Translate(null, "language", "text"));
            Assert.Throws <ArgumentNullException>(() => xmlTranslator.Translate(null, "text"));
            Assert.Throws <ArgumentNullException>(() => xmlTranslator.Translate("language", null));
            Assert.Throws <ArgumentException>(() => xmlTranslator.Translate(string.Empty, "text"));
            Assert.Throws <ArgumentException>(() => xmlTranslator.Translate("language", string.Empty));

            ITranslation translation;

            Assert.Throws <ArgumentNullException>(() => IYandexTranslatorExtensions.Translate(null, request => { }, out translation));
            Assert.Throws <ArgumentNullException>(() => xmlTranslator.Translate(null, out translation));

            TestTranslationResult(xmlTranslator.Translate("ru-en", "Привет, мир"));
            TestTranslationResult(xmlTranslator.Translate(t => t.From("ru").To("en").Text("Привет, мир")));
            Assert.True(xmlTranslator.Translate(t => t.From("ru").To("en").Text("Привет, мир"), out translation));
            TestTranslationResult(translation);

            TestTranslationResult(jsonTranslator.Translate("ru-en", "Привет, мир"));
            TestTranslationResult(jsonTranslator.Translate(t => t.From("ru").To("en").Text("Привет, мир")));
            Assert.True(jsonTranslator.Translate(t => t.From("ru").To("en").Text("Привет, мир"), out translation));
            TestTranslationResult(translation);
        }