コード例 #1
0
        public async Task EnsuresNonWhitespaceArguments(string whitespace)
        {
            var client = new DeploymentsClient(Substitute.For<IApiConnection>());

            await AssertEx.Throws<ArgumentException>(() => client.GetAll(whitespace, "name"));
            await AssertEx.Throws<ArgumentException>(() => client.GetAll("owner", whitespace));
        }
コード例 #2
0
        public async Task EnsuresNonNullArguments()
        {
            var client = new DeploymentsClient(Substitute.For<IApiConnection>());

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name"));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
        }
コード例 #3
0
        public async Task EnsuresNonEmptyArguments()
        {
            var client = new DeploymentsClient(Substitute.For<IApiConnection>());

            Assert.Throws<ArgumentException>(() => client.GetAll("", "name"));
            Assert.Throws<ArgumentException>(() => client.GetAll("owner", ""));
        }
コード例 #4
0
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);
            var expectedUrl = "repos/owner/name/deployments";

            client.GetAll("owner", "name");
            connection.Received(1).GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl));
        }
コード例 #5
0
        public void UsesPreviewAcceptsHeader()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);

            client.GetAll("owner", "name");
            connection.Received().GetAll<Deployment>(Arg.Any<Uri>(),
                                                     Arg.Any<IDictionary<string, string>>(),
                                                     ExpectedAcceptHeader);
        }
コード例 #6
0
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);
            var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);

            client.GetAll(owner, name);
            connection.Received(1)
                .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions);
        }
コード例 #7
0
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);
            var expectedUrl = string.Format("repositories/{0}/deployments", repositoryId);

            await client.GetAll(repositoryId);

            connection.Received(1)
                .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), 
                                    Args.ApiOptions);
        }
コード例 #8
0
        public async Task RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);
            var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);

            await client.GetAll(owner, name);

            connection.Received(1)
                .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null,
                                    "application/vnd.github.ant-man-preview+json", 
                                    Args.ApiOptions);
        }
コード例 #9
0
        public void RequestsCorrectUrlWithApiOptions()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);
            var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);

            var options = new ApiOptions
            {
                PageSize = 1,
                PageCount = 1,
                StartPage = 1
            };

            client.GetAll(owner, name, options);
            connection.Received(1)
                .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), options);
        }
コード例 #10
0
        public void RequestsCorrectUrlWithPreviewAcceptHeaders()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);
            var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name);

            client.GetAll(owner, name);
            connection.Received(1)
                .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                                    Arg.Any<IDictionary<string, string>>(),
                                    Arg.Is<string>(s => s == AcceptHeaders.DeploymentApiPreview),
                                    Args.ApiOptions);
        }
コード例 #11
0
        public async Task RequestsCorrectUrlWithRepostoryIdWithApiOptions()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentsClient(connection);
            var expectedUrl = string.Format("repositories/{0}/deployments", repositoryId);

            var options = new ApiOptions
            {
                PageSize = 1,
                PageCount = 1,
                StartPage = 1
            };

            await client.GetAll(repositoryId, options);

            connection.Received(1)
                .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                                    options);
        }