public void TestingTheRepoQualifier() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.Repo = "octokit.net"; client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+repo:octokit.net")); }
public void TestingTheRepoAndPathAndExtensionQualifiers() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.Repo = "octokit.net"; request.Path = "tools/FAKE.core"; request.Extension = "fs"; client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+path:tools/FAKE.core+extension:fs+repo:octokit.net")); }
public void TestingTheLanguageQualifier() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.Language = Language.CSharp; client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+language:C#")); }
public void TestingTheSizeQualifier_Range() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.Size = new Range(10, 100); client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+size:10..100")); }
public void TestingTheDefaultOrderParameter() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["order"] == "desc")); }
public void TestingTheInQualifier_Multiple() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.In = new[] { CodeInQualifier.File, CodeInQualifier.Path }; client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+in:file,path")); }
public void EnsuresNonNullArguments() { var client = new SearchClient(Substitute.For<IApiConnection>()); Assert.Throws<ArgumentNullException>(() => client.SearchCode(null)); }
public void TestingTheOrderParameter() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.SortField = CodeSearchSort.Indexed; request.Order = SortDirection.Ascending; client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["sort"] == "indexed" && d["order"] == "asc")); }
public async Task ErrorOccursWhenSpecifyingInvalidFormatForRepos() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("windows"); request.Repos = new RepositoryCollection { "haha-business" }; request.Order = SortDirection.Descending; await Assert.ThrowsAsync<RepositoryFormatException>( async () => await client.SearchCode(request)); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); client.SearchCode(new SearchCodeRequest("something")); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Any<Dictionary<string, string>>()); }
public void TestingTheFileNameQualifier() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.FileName = "packages.config"; client.SearchCode(request); connection.Received().Get<SearchCodeResult>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+filename:packages.config")); }
public async Task EnsuresNonNullArguments() { var client = new SearchClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.SearchCode(null)); }
public void TestingTheUserQualifier() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.User = "******"; client.SearchCode(request); connection.Received().GetAll<SearchCode>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+user:alfhenrik")); }
public void TestingTheSizeQualifier_LessThanOrEqual() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.Size = Range.LessThanOrEquals(10); client.SearchCode(request); connection.Received().GetAll<SearchCode>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+size:<=10")); }
public void TestingTheSortParameter() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); var request = new SearchCodeRequest("something"); request.SortField = CodeSearchSort.Indexed; client.SearchCode(request); connection.Received().GetAll<SearchCode>( Arg.Is<Uri>(u => u.ToString() == "search/code"), Arg.Is<Dictionary<string, string>>(d => d["sort"] == "indexed")); }