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)); }
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)); }
public async Task EnsuresNonEmptyArguments() { var client = new DeploymentsClient(Substitute.For<IApiConnection>()); Assert.Throws<ArgumentException>(() => client.GetAll("", "name")); Assert.Throws<ArgumentException>(() => client.GetAll("owner", "")); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }