示例#1
0
            public void GetsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoriesClient(connection);

                client.GetBranch("owner", "repo", "branch");

                connection.Received()
                .Get <Branch>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/repo/branches/branch"), null, "application/vnd.github.loki-preview+json");
            }
示例#2
0
            public void EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For <IApiConnection>());

                Assert.Throws <ArgumentNullException>(() => client.GetBranch(null, "repo", "branch"));
                Assert.Throws <ArgumentNullException>(() => client.GetBranch("owner", null, "branch"));
                Assert.Throws <ArgumentNullException>(() => client.GetBranch("owner", "repo", null));
                Assert.Throws <ArgumentException>(() => client.GetBranch("", "repo", "branch"));
                Assert.Throws <ArgumentException>(() => client.GetBranch("owner", "", "branch"));
                Assert.Throws <ArgumentException>(() => client.GetBranch("owner", "repo", ""));
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoriesClient(Substitute.For<IApiConnection>());

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

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

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetBranch("", "repo", "branch"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetBranch("owner", "", "branch"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetBranch("owner", "repo", ""));
            }
            public async Task RequestsTheCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                await client.GetBranch(1, "branch");

                connection.Received()
                    .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch"), null, "application/vnd.github.loki-preview+json");
            }
示例#5
0
            public void GetsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoriesClient(connection);

                client.GetBranch("owner", "repo", "branch");

                connection.Received()
                    .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch"), null);
            }