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 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 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 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 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)); }
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"); }