public void EnsuresNonNullArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableRepositoryContentsClient(gitHubClient); Assert.Throws <ArgumentNullException>(() => client.UpdateFile(null, "repo", "path/to/file", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); Assert.Throws <ArgumentNullException>(() => client.UpdateFile("org", null, "path/to/file", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); Assert.Throws <ArgumentNullException>(() => client.UpdateFile("org", "repo", null, new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); Assert.Throws <ArgumentNullException>(() => client.UpdateFile("org", "repo", "path/to/file", null)); Assert.Throws <ArgumentNullException>(() => client.UpdateFile(1, null, new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); Assert.Throws <ArgumentNullException>(() => client.UpdateFile(1, "path/to/file", null)); Assert.Throws <ArgumentException>(() => client.UpdateFile("", "repo", "path/to/file", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); Assert.Throws <ArgumentException>(() => client.UpdateFile("org", "", "path/to/file", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); Assert.Throws <ArgumentException>(() => client.UpdateFile("org", "repo", "", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); Assert.Throws <ArgumentException>(() => client.UpdateFile(1, "", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch"))); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableRepositoryContentsClient(gitHubClient); string expectedUri = "repos/org/repo/contents/path/to/file"; client.UpdateFile("org", "repo", "path/to/file", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch")); gitHubClient.Connection.Received().Put <RepositoryContentChangeSet>(Arg.Is <Uri>(u => u.ToString() == expectedUri), Arg.Any <object>()); }
public void RequestsCorrectUrlWithRepositoryIdWithExplicitBase64() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableRepositoryContentsClient(gitHubClient); string expectedUri = "repositories/1/contents/path/to/file"; client.UpdateFile(1, "path/to/file", new UpdateFileRequest("message", "bXlmaWxlY29udGVudHM=", "1234abc", "mybranch", false)); gitHubClient.Connection.Received().Put <RepositoryContentChangeSet>(Arg.Is <Uri>(u => u.ToString() == expectedUri), Arg.Any <object>()); }
public void PassesRequestObjectWithRepositoriesIdWithExplicitBase64() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableRepositoryContentsClient(gitHubClient); client.UpdateFile(1, "path/to/file", new UpdateFileRequest("message", "bXlmaWxlY29udGVudHM=", "1234abc", "mybranch", false)); gitHubClient.Connection.Received().Put <RepositoryContentChangeSet>( Arg.Any <Uri>(), Arg.Is <UpdateFileRequest>(a => a.Message == "message" && a.Content == "bXlmaWxlY29udGVudHM=" && a.Sha == "1234abc" && a.Branch == "mybranch")); }
public void PassesRequestObject() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableRepositoryContentsClient(gitHubClient); client.UpdateFile("org", "repo", "path/to/file", new UpdateFileRequest("message", "myfilecontents", "1234abc", "mybranch")); gitHubClient.Connection.Received().Put <RepositoryContentChangeSet>( Arg.Any <Uri>(), Arg.Is <UpdateFileRequest>(a => a.Message == "message" && a.Content == "myfilecontents" && a.Sha == "1234abc" && a.Branch == "mybranch")); }