public async Task ReturnsReadme()
            {
                string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
                var readmeInfo = new ReadmeResponse(
                    encodedContent,
                    "README.md",
                    "https://github.example.com/readme",
                    "https://github.example.com/readme.md",
                    "base64");
                var connection = Substitute.For<IApiConnection>();
                connection.Get<ReadmeResponse>(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
                connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
                var contentsClient = new RepositoryContentsClient(connection);

                var readme = await contentsClient.GetReadme("fake", "repo");

                Assert.Equal("README.md", readme.Name);
                connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
                    null);
                connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme"),
                    null);
                var htmlReadme = await readme.GetHtmlContent();
                Assert.Equal("<html>README</html>", htmlReadme);
                connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme.md"), null);
            }
            public async Task RequestsCorrectUrlWithRepositoryIdWithExplicitBase64()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                string expectedUri = "repositories/1/contents/path/to/file";
                await client.CreateFile(1, "path/to/file", new CreateFileRequest("message", "bXlmaWxlY29udGVudHM=", "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.DeleteFile("org", "repo", "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

                connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == expectedUri), Arg.Any <object>());
            }
            public async Task ReturnsReadmeHtml()
            {
                var connection = Substitute.For<IApiConnection>();
                connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
                var contentsClient = new RepositoryContentsClient(connection);

                var readme = await contentsClient.GetReadmeHtml("fake", "repo");

                connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"), null);
                Assert.Equal("<html>README</html>", readme);
            }
            public async Task ReturnsArchiveLinkAsZipball()
            {
                var connection = Substitute.For<IApiConnection>();
                connection.GetRedirect(Args.Uri).Returns(Task.FromResult("https://codeload.github.com/fake/repo/legacy.tar.gz/master"));
                var contentsClient = new RepositoryContentsClient(connection);

                var archiveLink = await contentsClient.GetArchiveLink("fake", "repo", ArchiveFormat.Zipball);

                connection.Received().GetRedirect(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/zipball/"));
                Assert.Equal("https://codeload.github.com/fake/repo/legacy.tar.gz/master", archiveLink);
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetReadme(null, "name"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetReadme("owner", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetReadme("", "name"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetReadme("owner", ""));
            }
Exemple #7
0
            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>());
            }
Exemple #8
0
            public void EnsurePassingCorrectParameters()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                client.GetArchive("org", "repo", ArchiveFormat.Tarball, "dev");

                const string expectedUri      = "repos/org/repo/tarball/dev";
                var          expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get <byte[]>(Arg.Is <Uri>(uri => uri.ToString() == expectedUri), Arg.Is <TimeSpan>(span => span == expectedTimeSpan));
            }
            public async Task ReturnsReadmeHtmlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();

                connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
                var contentsClient = new RepositoryContentsClient(connection);

                var readme = await contentsClient.GetReadmeHtml(1);

                connection.Received().GetHtml(Arg.Is <Uri>(u => u.ToString() == "repositories/1/readme"), null);
                Assert.Equal("<html>README</html>", readme);
            }
            public async Task RequestsCorrectUrl1()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await client.GetArchive("org", "repo");

                const string expectedUri      = "repos/org/repo/tarball/";
                var          expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get <byte[]>(Arg.Is <Uri>(uri => uri.ToString() == expectedUri), Arg.Is <TimeSpan>(span => span == expectedTimeSpan));
            }
            public async Task RequestsCorrectUrl4WithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await client.GetArchive(1, ArchiveFormat.Zipball, "ref", TimeSpan.FromMinutes(60));

                const string expectedUri      = "repositories/1/zipball/ref";
                var          expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get <byte[]>(Arg.Is <Uri>(uri => uri.ToString() == expectedUri), Arg.Is <TimeSpan>(span => span == expectedTimeSpan));
            }
Exemple #12
0
            public async Task ReturnsArchiveLinkWithSpecifiedValues()
            {
                var connection = Substitute.For <IApiConnection>();

                connection.GetRedirect(Args.Uri).Returns(Task.FromResult("https://codeload.github.com/fake/repo/legazy.zip/release"));
                var contentsClient = new RepositoryContentsClient(connection);

                var archiveLink = await contentsClient.GetArchiveLink("fake", "repo", ArchiveFormat.Zipball, "release");

                connection.Received().GetRedirect(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/zipball/release"));
                Assert.Equal("https://codeload.github.com/fake/repo/legazy.zip/release", archiveLink);
            }
Exemple #13
0
            public async Task ReturnsArchiveLinkWithDefaults()
            {
                var connection = Substitute.For <IApiConnection>();

                connection.GetRedirect(Args.Uri).Returns(Task.FromResult("https://codeload.github.com/fake/repo/legacy.tar.gz/master"));
                var contentsClient = new RepositoryContentsClient(connection);

                var archiveLink = await contentsClient.GetArchiveLink("fake", "repo");

                connection.Received().GetRedirect(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/tarball/"));
                Assert.Equal("https://codeload.github.com/fake/repo/legacy.tar.gz/master", archiveLink);
            }
            public async Task ReturnsContentsByRef()
            {
                List<RepositoryContent> result = new List<RepositoryContent> { new RepositoryContent() };

                var connection = Substitute.For<IApiConnection>();
                connection.GetAll<RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList<RepositoryContent>));
                var contentsClient = new RepositoryContentsClient(connection);

                var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "readme.md", "master");

                connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/readme.md?ref=master"));
                Assert.Equal(1, contents.Count);
            }
Exemple #15
0
            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 async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetReadme(null, "name"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetReadme("owner", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetReadme("", "name"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetReadme("owner", ""));
            }
            public async Task PassesRequestObjectWithExplicitBase64()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await client.CreateFile("org", "repo", "path/to/file", new CreateFileRequest("message", "bXlmaWxlY29udGVudHM=", "mybranch", false));

                connection.Received().Put <RepositoryContentChangeSet>(
                    Arg.Any <Uri>(),
                    Arg.Is <CreateFileRequest>(a =>
                                               a.Message == "message" &&
                                               a.Content == "bXlmaWxlY29udGVudHM=" &&
                                               a.Branch == "mybranch"));
            }
            public async Task ReturnsRawContent()
            {
                var result = new byte[] { 1, 2, 3 };

                var connection = Substitute.For <IApiConnection>();

                connection.GetRaw(Args.Uri, default).Returns(result);
                var contentsClient = new RepositoryContentsClient(connection);

                var rawContent = await contentsClient.GetRawContentByRef("fake", "repo", "path/to/file.txt", "reference");

                connection.Received().GetRaw(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/contents/path/to/file.txt?ref=reference"), null);
                Assert.Same(result, rawContent);
            }
            public async Task PassesRequestObjectWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await client.CreateFile(1, "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch"));

                connection.Received().Put <RepositoryContentChangeSet>(
                    Arg.Any <Uri>(),
                    Arg.Is <CreateFileRequest>(a =>
                                               a.Message == "message" &&
                                               a.Content == "myfilecontents" &&
                                               a.Branch == "mybranch"));
            }
            public async Task PassesRequestObjectWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await client.DeleteFile(1, "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

                connection.Received().Delete(
                    Arg.Any <Uri>(),
                    Arg.Is <DeleteFileRequest>(a =>
                                               a.Message == "message" &&
                                               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.GetArchive(null, "repo"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", ""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.Zero));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive(1, ArchiveFormat.Tarball, "ref", TimeSpan.Zero));
            }
            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 == "bXlmaWxlY29udGVudHM=" &&
                                               a.Sha == "1234abc" &&
                                               a.Branch == "mybranch"));
            }
Exemple #23
0
            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 async Task ReturnsAllContentsByRefWithRepositoryId()
            {
                var result = new List <RepositoryContent> {
                    new RepositoryContent()
                };

                var connection = Substitute.For <IApiConnection>();

                connection.GetAll <RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList <RepositoryContent>));
                var contentsClient = new RepositoryContentsClient(connection);

                var contents = await contentsClient.GetAllContentsByRef(1, "master");

                connection.Received().GetAll <RepositoryContent>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/contents/?ref=master"));
                Assert.Equal(1, contents.Count);
            }
            public async Task ReturnsContents()
            {
                var result = new List <RepositoryContent> {
                    new RepositoryContent()
                };

                var connection = Substitute.For <IApiConnection>();

                connection.GetAll <RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList <RepositoryContent>));
                var contentsClient = new RepositoryContentsClient(connection);

                var contents = await contentsClient.GetAllContents("fake", "repo", "readme.md");

                connection.Received().GetAll <RepositoryContent>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/contents/readme.md"));
                Assert.Equal(1, contents.Count);
            }
            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 PassesRequestObjectWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await client.CreateFile(1, "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch"));

                connection.Received().Put<RepositoryContentChangeSet>(
                    Arg.Any<Uri>(),
                    Arg.Is<CreateFileRequest>(a =>
                        a.Message == "message"
                        && a.Content == "bXlmaWxlY29udGVudHM="
                        && a.Branch == "mybranch"));
            }
            public async Task RequestsCorrectUrl4WithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await client.GetArchive(1, ArchiveFormat.Zipball, "ref", TimeSpan.FromMinutes(60));

                const string expectedUri = "repositories/1/zipball/ref";
                var expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get<byte[]>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<TimeSpan>(span => span == expectedTimeSpan));
            }
            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 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 RequestsCorrectUrl1()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await client.GetArchive("org", "repo");

                const string expectedUri = "repos/org/repo/tarball/";
                var expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get<byte[]>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<TimeSpan>(span => span == expectedTimeSpan));
            }
            public void EnsurePassingCorrectParameters()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                client.GetArchive("org", "repo", ArchiveFormat.Tarball, "dev");

                const string expectedUri = "repos/org/repo/tarball/dev";
                var expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get<byte[]>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<TimeSpan>(span => span == expectedTimeSpan));
            }
            public async Task ReturnsAllContentsWithRepositoryId()
            {
                var result = new List<RepositoryContent> { new RepositoryContent() };

                var connection = Substitute.For<IApiConnection>();
                connection.GetAll<RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList<RepositoryContent>));
                var contentsClient = new RepositoryContentsClient(connection);

                var contents = await contentsClient.GetAllContents(1);

                connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/"));
                Assert.Equal(1, contents.Count);
            }
            public async Task PassesRequestObjectWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await client.DeleteFile(1, "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

                connection.Received().Delete(
                    Arg.Any<Uri>(),
                    Arg.Is<DeleteFileRequest>(a =>
                        a.Message == "message"
                        && a.Sha == "1234abc"
                        && a.Branch == "mybranch"));
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                string expectedUri = "repositories/1/contents/path/to/file";
                await client.DeleteFile(1, "path/to/file", new DeleteFileRequest("message", "1234abc", "mybranch"));

                connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.Zero));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive(1, ArchiveFormat.Tarball, "ref", TimeSpan.Zero));
            }