Exemplo n.º 1
0
        public void GenerateInvalidUrlWithFormatException()
        {
            var opt = new YandexSearchOption()
            {
                BaseUrl =
                    "https://yandex.com/search/xml?user={&key={1}&query={2}&l10n=en&sortby=rlv&filter=none&groupby=attr%3D%22%22.mode%3Dflat.groups-on-page%3D10.docs-in-group%3D1",
            };
            var yse = new YandexSearchEngine(opt);

            Assert.Throws <FormatException>(() => yse.GetFormattedSearchUrl(null));
        }
Exemplo n.º 2
0
        public void GenerateValidUrl()
        {
            var opt = new YandexSearchOption()
            {
                BaseUrl =
                    "https://yandex.com/search/xml?user={0}&key={1}&query={2}&l10n=en&sortby=rlv&filter=none&groupby=attr%3D%22%22.mode%3Dflat.groups-on-page%3D10.docs-in-group%3D1",
                Key = "key", User = "******"
            };
            var yse        = new YandexSearchEngine(opt);
            var searchText = "Привет";
            var url        = yse.GetFormattedSearchUrl(searchText);

            Assert.True(!string.IsNullOrWhiteSpace(url), "url is null or whitespace");
        }