コード例 #1
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryBranchesClient(Substitute.For <IApiConnection>());
                var update = new BranchUpdate();

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(null, "repo", "branch", update));

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(1, null, update));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(1, "branch", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("", "repo", "branch", update));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("owner", "", "branch", update));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("owner", "repo", "", update));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Edit(1, "", update));
            }
コード例 #2
0
            public void RequestsTheCorrectUrlWithRepositoryId()
            {
                var          connection           = Substitute.For <IApiConnection>();
                var          client               = new RepositoryBranchesClient(connection);
                var          update               = new BranchUpdate();
                const string previewAcceptsHeader = "application/vnd.github.loki-preview+json";

                client.Edit(1, "branch", update);

                connection.Received()
                .Patch <Branch>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/branches/branch"), Arg.Any <BranchUpdate>(), previewAcceptsHeader);
            }
コード例 #3
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>());
                var update = new BranchUpdate();

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(null, "repo", "branch", update));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit("owner", null, "branch", update));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit("owner", "repo", null, update));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit("owner", "repo", "branch", null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(1, null, update));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(1, "branch", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("", "repo", "branch", update));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("owner", "", "branch", update));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Edit("owner", "repo", "", update));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Edit(1, "", update));
            }
コード例 #4
0
            public void RequestsTheCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryBranchesClient(connection);
                var update = new BranchUpdate();
                const string previewAcceptsHeader = "application/vnd.github.loki-preview+json";

                client.Edit(1, "branch", update);

                connection.Received()
                    .Patch<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch"), Arg.Any<BranchUpdate>(), previewAcceptsHeader);
            }