public void GenerateInvalidUrlWithFormatException() { var opt = new GoogleSearchOption() { BaseUrl = "https://www.googleapis.com/customsearch/v1?cx={0}&key=}&q={2}", Key = "key", Cx = "cx" }; var gse = new GoogleSearchEngine(opt); Assert.Throws <FormatException>(() => gse.GetFormattedSearchUrl(null)); }
public void GenerateValidUrl() { var opt = new GoogleSearchOption() { BaseUrl = "https://www.googleapis.com/customsearch/v1?cx={0}&key={1}&q={2}", Key = "key", Cx = "cx" }; var gse = new GoogleSearchEngine(opt); var searchText = "Привет"; var url = gse.GetFormattedSearchUrl(searchText); Assert.True(!string.IsNullOrWhiteSpace(url), "url is null or whitespace"); }