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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
        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), 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 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);
        }
Exemple #9
0
        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 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,application/vnd.github.flash-preview+json",
                                  Args.ApiOptions);
        }
Exemple #11
0
        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 async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
        {
            var connection  = Substitute.For <IApiConnection>();
            var client      = new DeploymentStatusClient(connection);
            var expectedUrl = "repositories/1/deployments/1/statuses";

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

            await client.GetAll(1, 1, options);

            connection.Received().GetAll <DeploymentStatus>(Arg.Is <Uri>(u => u.ToString() == expectedUrl),
                                                            null,
                                                            "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
                                                            options);
        }