public void Cunstructor_NullQueryAndNoCredentials() { int querySearchExceptionCount = 0; _unitUnderTest = new BingSearch(new Uri(CnstUrl)); _unitUnderTest.QuerySearchExceptionAsync += (s, e) => ++querySearchExceptionCount; _unitUnderTest.ExecuteAsync(null); Thread.Sleep(2000); //sleep since the events are async and may not complete before returning Assert.AreEqual(1, querySearchExceptionCount); }
private static void Main(string[] args) { var s = new List<string> {"Xbox"}; var search = new BingSearch(new Uri(ConfigurationManager.AppSettings[CnstUrl])) { Credentials = new NetworkCredential(ConfigurationManager.AppSettings[CnstAccesskey], ConfigurationManager.AppSettings[CnstAccesskey]) }; search.QuerySearchCompletedAsync += search_QuerySearchCompletedAsync; search.QuerySearchExceptionAsync += search_QuerySearchExceptionAsync; search.ExecuteAsync(null); Console.ReadLine(); }
public void Cunstructor_ValidQueryWithResponse() { int querySearchCompletedCount = 0; _unitUnderTest = new BingSearch(new Uri(CnstUrl)) { Credentials = new NetworkCredential(CnstAccesskey, CnstAccesskey) }; _unitUnderTest.QuerySearchCompletedAsync += (s, e) => ++querySearchCompletedCount; var query = new List<string> {"Xbox"}; _unitUnderTest.ExecuteAsync(query); Thread.Sleep(2000); //sleep since the events are async and may not complete before returning Assert.AreEqual(1, querySearchCompletedCount); }
public void Search_QuerySearchExceptionAsyncEventsFiresWrongUrl() { int querySearchExceptionCount = 0; _unitUnderTest = new BingSearch(new Uri("http://localhost/")); _unitUnderTest.QuerySearchExceptionAsync += (s, e) => ++querySearchExceptionCount; _unitUnderTest.Credentials = new NetworkCredential(CnstAccesskey, CnstAccesskey); var query = new List<string> {"xbox"}; _unitUnderTest.ExecuteAsync(query); Thread.Sleep(2000); //sleep since the events are async and may not complete before returning Assert.AreEqual(1, querySearchExceptionCount); }