示例#1
0
 public void TestingTheTermParameter()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github"));
 }
示例#2
0
 public void TestingTheAccountTypeQualifier_Org()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     request.AccountType = AccountType.Org;
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+type:Org"));
 }
 public void TestingTheInQualifier()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     //get users where the fullname contains 'github'
     var request = new SearchUsersRequest("github");
     request.In = new[] { UserInQualifier.Fullname };
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+in:Fullname"));
 }
 /// <summary>
 /// search users
 /// http://developer.github.com/v3/search/#search-users
 /// </summary>
 /// <param name="request"></param>
 /// <returns>List of users</returns>
 public IObservable<User> SearchUsers(SearchUsersRequest request)
 {
     Ensure.ArgumentNotNull(request, "request");
     return _connection.GetAndFlattenAllPages<User>(ApiUrls.SearchUsers(), request.ToParametersDictionary());
 }
示例#5
0
 public void TestingTheInQualifier_Email()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     request.In = new[] { UserInQualifier.Email };
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+in:Email"));
 }
示例#6
0
 public void TestingTheFollowersQualifier_Range()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     request.Followers = new Range(1, 1000);
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+followers:1..1000"));
 }
示例#7
0
 public void TestingTheCreatedQualifier_LessThan()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     request.Created = DateRange.LessThan(new DateTime(2014, 1, 1));
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+created:<2014-01-01"));
 }
示例#8
0
 public void TestingTheLanguageQualifier()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     //get users who have mostly repos where language is Ruby
     var request = new SearchUsersRequest("github");
     request.Language = Language.Ruby;
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+language:Ruby"));
 }
示例#9
0
 public void TestingTheLocationQualifier()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     request.Location = "San Francisco";
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+location:San Francisco"));
 }
示例#10
0
 public void TestingTheReposQualifier_LessThan()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     request.Repositories = Range.LessThan(5);
     client.SearchUsers(request);
     connection.Received().Get<SearchUsersResult>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+repos:<5"));
 }
 /// <summary>
 /// search users
 /// http://developer.github.com/v3/search/#search-users
 /// </summary>
 /// <param name="search"></param>
 /// <returns>List of users</returns>
 public IObservable<SearchUsersResult> SearchUsers(SearchUsersRequest search)
 {
     Ensure.ArgumentNotNull(search, "search");
     return _client.SearchUsers(search).ToObservable();
 }
示例#12
0
 public void TestingTheFollowersQualifier_LessThanOrEqualTo()
 {
     var connection = Substitute.For<IApiConnection>();
     var client = new SearchClient(connection);
     var request = new SearchUsersRequest("github");
     request.Followers = Range.LessThanOrEquals(1);
     client.SearchUsers(request);
     connection.Received().GetAll<User>(
         Arg.Is<Uri>(u => u.ToString() == "search/users"),
         Arg.Is<Dictionary<string, string>>(d => d["q"] == "github+followers:<=1"));
 }
 /// <summary>
 /// search users
 /// http://developer.github.com/v3/search/#search-users
 /// </summary>
 /// <param name="search"></param>
 /// <returns>List of users</returns>
 public IObservable<User> SearchUsers(SearchUsersRequest search)
 {
     Ensure.ArgumentNotNull(search, "search");
     return _connection.GetAndFlattenAllPages<User>(ApiUrls.SearchUsers(), search.Parameters);
 }