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

            Assert.Throws <ArgumentException>(() => client.Create(whitespace, "repo", 1, newDeploymentStatus));
            Assert.Throws <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));
        }
Esempio n. 3
0
        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>());
        }
        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 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 == "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json"));
        }
        public void PostsToCorrectUrlWithRepositoryId()
        {
            var connection  = Substitute.For <IApiConnection>();
            var client      = new DeploymentStatusClient(connection);
            var expectedUrl = "repositories/1/deployments/1/statuses";

            client.Create(1, 1, newDeploymentStatus);

            connection.Received().Post <DeploymentStatus>(Arg.Is <Uri>(u => u.ToString() == expectedUrl),
                                                          Arg.Any <NewDeploymentStatus>(),
                                                          "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json");
        }
        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");
        }
        public async Task EnsuresNonNullArguments()
        {
            var client = new DeploymentStatusClient(Substitute.For <IApiConnection>());

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", 1, newDeploymentStatus));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", null, 1, newDeploymentStatus));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", "name", 1, null));

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

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

            await Assert.ThrowsAsync <ArgumentException>(() => client.Create("owner", "", 1, newDeploymentStatus));
        }