コード例 #1
0
            public void EnsuresNonNullArguments()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryContentsClient(gitHubClient);

                Assert.Throws <ArgumentNullException>(() => client.CreateFile(null, "repo", "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch")));
                Assert.Throws <ArgumentNullException>(() => client.CreateFile("org", null, "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch")));
                Assert.Throws <ArgumentNullException>(() => client.CreateFile("org", "repo", null, new CreateFileRequest("message", "myfilecontents", "mybranch")));
                Assert.Throws <ArgumentNullException>(() => client.CreateFile("org", "repo", "path/to/file", null));

                Assert.Throws <ArgumentNullException>(() => client.CreateFile(1, null, new CreateFileRequest("message", "myfilecontents", "mybranch")));
                Assert.Throws <ArgumentNullException>(() => client.CreateFile(1, "path/to/file", null));

                Assert.Throws <ArgumentException>(() => client.CreateFile("", "repo", "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch")));
                Assert.Throws <ArgumentException>(() => client.CreateFile("org", "", "path/to/file", new CreateFileRequest("message", "myfilecontents", "mybranch")));
                Assert.Throws <ArgumentException>(() => client.CreateFile("org", "repo", "", new CreateFileRequest("message", "myfilecontents", "mybranch")));

                Assert.Throws <ArgumentException>(() => client.CreateFile(1, "", new CreateFileRequest("message", "myfilecontents", "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.CreateFile("org", "repo", "path/to/file", new CreateFileRequest("message", "myfilecontents", "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.CreateFile(1, "path/to/file", new CreateFileRequest("message", "bXlmaWxlY29udGVudHM=", "mybranch", false));

                gitHubClient.Connection.Received().Put <RepositoryContentChangeSet>(Arg.Is <Uri>(u => u.ToString() == expectedUri), Arg.Any <object>());
            }
コード例 #4
0
            public void PassesRequestObjectWithRepositoryIdWithExplicitBase64()
            {
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client       = new ObservableRepositoryContentsClient(gitHubClient);

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

                gitHubClient.Connection.Received().Put <RepositoryContentChangeSet>(
                    Arg.Any <Uri>(),
                    Arg.Is <CreateFileRequest>(a =>
                                               a.Message == "message" &&
                                               a.Content == "bXlmaWxlY29udGVudHM=" &&
                                               a.Branch == "mybranch"));
            }
コード例 #5
0
            public void PassesRequestObject()
            {
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client       = new ObservableRepositoryContentsClient(gitHubClient);

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

                gitHubClient.Connection.Received().Put <RepositoryContentChangeSet>(
                    Arg.Any <Uri>(),
                    Arg.Is <CreateFileRequest>(a =>
                                               a.Message == "message" &&
                                               a.Content == "myfilecontents" &&
                                               a.Branch == "mybranch"));
            }