public void BeginLookup_WithNoIds_ThrowsException() { var twitterClient = Substitute.For<IBaseTwitterClient>(); var users = new Users(twitterClient); // act users.BeginLookup(null, (a, b, c) => { }); twitterClient.DidNotReceive().BeginRequest(Arg.Any<string>(), Arg.Any<IDictionary<string, string>>(), Arg.Any<WebMethod>(), Arg.Any<RestCallback>()); }
public void BeginLookup_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.BeginLookup(new[] { 1,2 }, endSearch); Assert.That(wasCalled, Errors.CallbackDidNotFire); }
public void BeginLookup_WithOneId_SetsParameterCorrectly() { var values = new[] { 1, 2 }; const string expected = "1,2"; 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("user_id", expected)); var users = new Users(twitterClient); GenericResponseDelegate endSearch = (a, b, c) => { }; // act users.BeginLookup(values, endSearch); }