public async Task EnsureNonWhitespaceArguments(string whitespace)
        {
            var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());

            await Assert.ThrowsAsync<ArgumentException>(() => client.Create(whitespace, "repo", 1, newDeploymentStatus));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", whitespace, 1, newDeploymentStatus));
        }
 public void EnsuresNonNullArguments()
 {
     var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());
         
     Assert.Throws<ArgumentNullException>(() => client.Create(null, "name", 1, newDeploymentStatus));
     Assert.Throws<ArgumentNullException>(() => client.Create("owner", null, 1, newDeploymentStatus));
 }
 public void EnsuresNonEmptyArguments()
 {
     var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());
         
     Assert.Throws<ArgumentException>(() => client.GetAll("", "name", 1));
     Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", 1));
 }
 public void EnsureNonWhitespaceArguments(string whitespace)
 {
     var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());
         
     Assert.Throws<ArgumentException>(() => client.GetAll(whitespace, "name", 1));
     Assert.Throws<ArgumentException>(() => client.GetAll("owner", whitespace, 1));
 }
        public async Task EnsuresNonNullArguments()
        {
            var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", 1));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, 1));
        }
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repos/owner/name/deployments/1/statuses";

            client.GetAll("owner", "name", 1);
            connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl));
        }
        public async Task EnsureNonWhitespaceArguments(string whitespace)
        {
            var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());

            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll(whitespace, "name", 1));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", whitespace, 1));

            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll(whitespace, "name", 1, ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", whitespace, 1, ApiOptions.None));
        }
        public async Task EnsuresNonEmptyArguments()
        {
            var client = new DeploymentStatusClient(Substitute.For<IApiConnection>());

            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", 1));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", 1));

            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", 1, ApiOptions.None));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", 1, ApiOptions.None));
        }
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repositories/1/deployments/1/statuses";

            await client.GetAll(1, 1);

            connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions);
        }
        public void UsesPreviewAcceptHeader()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);

            client.GetAll("owner", "name", 1);
            connection.Received().GetAll<DeploymentStatus>(Arg.Any<Uri>(),
                                                           Arg.Any<IDictionary<string, string>>(),
                                                           expectedAcceptsHeader);
        }
        public async Task RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repos/owner/name/deployments/1/statuses";

            await client.GetAll("owner", "name", 1);

            connection.Received().GetAll<
                DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                null,
                "application/vnd.github.ant-man-preview+json",
                Args.ApiOptions);
        }
        public void RequestsCorrectUrlWithApiOptions()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repos/owner/name/deployments/1/statuses";

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

            client.GetAll("owner", "name", 1, options);
            connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), options);
        }
        public void SendsPreviewAcceptHeaders()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repos/owner/repo/deployments/1/statuses";

            client.Create("owner", "repo", 1, newDeploymentStatus);

            connection.Received(1).Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                                                          Arg.Any<NewDeploymentStatus>(),
                                                          Arg.Is<string>(s => s == AcceptHeaders.DeploymentApiPreview));
        }
        public void RequestsCorrectUrlWithPreviewAcceptHeaders()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repos/owner/name/deployments/1/statuses";

            client.GetAll("owner", "name", 1);
            connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                                                           Arg.Any<IDictionary<string, string>>(),
                                                           Arg.Is<string>(a => a == AcceptHeaders.DeploymentApiPreview),
                                                           Args.ApiOptions);
        }
        public void UsesPreviewAcceptHeader()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);

            client.Create("owner", "repo", 1, newDeploymentStatus);

            connection.Received().Post<DeploymentStatus>(Arg.Any<Uri>(),
                                                         Arg.Any<NewDeploymentStatus>(),
                                                         expectedAcceptsHeader);
        }
        public void PostsToCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repos/owner/repo/deployments/1/statuses";

            client.Create("owner", "repo", 1, newDeploymentStatus);

            connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                                                         Arg.Any<NewDeploymentStatus>(),
                                                         Arg.Any<string>());
        }
        public void PostsToCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new DeploymentStatusClient(connection);
            var expectedUrl = "repos/owner/repo/deployments/1/statuses";

            client.Create("owner", "repo", 1, newDeploymentStatus);

            connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                newDeploymentStatus,
                "application/vnd.github.ant-man-preview+json");
        }
Beispiel #18
0
 /// <summary>
 /// Instantiates a new GitHub Repository Deployments API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public DeploymentsClient(IApiConnection apiConnection)
     : base(apiConnection)
 {
     Status = new DeploymentStatusClient(apiConnection);
 }
 /// <summary>
 /// Instantiates a new GitHub Repository Deployments API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public DeploymentsClient(IApiConnection apiConnection)
     : base(apiConnection)
 {
     Status = new DeploymentStatusClient(apiConnection);
 }