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