コード例 #1
0
            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")));
            }
コード例 #2
0
            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>());
            }
コード例 #3
0
            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>());
            }
コード例 #4
0
            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"));
            }
コード例 #5
0
            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"));
            }