public void BeginSearch_WithValidUser_SetsParameter() { const string username = "******"; var twitterClient = Substitute.For<IBaseTwitterClient>(); twitterClient.When(a => a.BeginRequest(Arg.Any<string>(), Arg.Any<IDictionary<string, string>>(), Arg.Any<WebMethod>(), Arg.Any<RestCallback>())) .Do(c => c.AssertParameter("q", username)); var users = new Users(twitterClient); GenericResponseDelegate endSearch = (a, b, c) => { }; // act users.BeginSearch(username, endSearch); }
public void BeginSearch_WithValidUser_ReturnsUsers() { var wasCalled = false; var twitterClient = Substitute.For<IBaseTwitterClient>(); twitterClient.SetReponseBasedOnRequestPath(); var users = new Users(twitterClient); // assert GenericResponseDelegate endSearch = (a, b, c) => { wasCalled = true; var results = c as IEnumerable<User>; Assert.That(results, Is.Not.Empty); }; // act users.BeginSearch("abcde", endSearch); Assert.That(wasCalled, Errors.CallbackDidNotFire); }