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 Search_QuerySearchCompletedAsyncEventsFires() { int querySearchCompletedCount = 0; _unitUnderTest = new BingSearch(new Uri(CnstUrl)); _unitUnderTest.QuerySearchCompletedAsync += (s, e) => ++querySearchCompletedCount; _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, querySearchCompletedCount); }