public async Task EnsuresNonNullArguments() { var deployKeysClient = new RepositoryDeployKeysClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => deployKeysClient.Create(null, "repo", new NewDeployKey())); await Assert.ThrowsAsync <ArgumentNullException>(() => deployKeysClient.Create("user", null, new NewDeployKey())); await Assert.ThrowsAsync <ArgumentNullException>(() => deployKeysClient.Create("user", "repo", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => deployKeysClient.Create(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => deployKeysClient.Create("", "repo", new NewDeployKey())); await Assert.ThrowsAsync <ArgumentException>(() => deployKeysClient.Create("user", "", new NewDeployKey())); await Assert.ThrowsAsync <ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey())); await Assert.ThrowsAsync <ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey { Key = "ABC123" })); await Assert.ThrowsAsync <ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey { Title = "user@repo" })); }
public void SendsCreateToCorrectUrl() { var apiConnection = Substitute.For<IApiConnection>(); var deployKeysClient = new RepositoryDeployKeysClient(apiConnection); deployKeysClient.Create("user", "repo", new NewDeployKey { Key = "ABC123", Title = "user@repo" }); apiConnection.Received().Post<DeployKey>(Arg.Is<Uri>(u => u.ToString() == "repos/user/repo/keys"), Args.NewDeployKey); }
public void SendsCreateToCorrectUrl() { var apiConnection = Substitute.For <IApiConnection>(); var deployKeysClient = new RepositoryDeployKeysClient(apiConnection); deployKeysClient.Create("user", "repo", new NewDeployKey { Key = "ABC123", Title = "user@repo" }); apiConnection.Received().Post <DeployKey>(Arg.Is <Uri>(u => u.ToString() == "repos/user/repo/keys"), Args.NewDeployKey); }
public void CreatesCorrectUrlWithRepositoryId() { var apiConnection = Substitute.For <IApiConnection>(); var deployKeysClient = new RepositoryDeployKeysClient(apiConnection); var newDeployKey = new NewDeployKey { Key = "ABC123", Title = "user@repo" }; deployKeysClient.Create(1, newDeployKey); apiConnection.Received().Post <DeployKey>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/keys"), newDeployKey); }
public async Task EnsuresNonNullArguments() { var deployKeysClient = new RepositoryDeployKeysClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => deployKeysClient.Create(null, "repo", new NewDeployKey())); await Assert.ThrowsAsync<ArgumentNullException>(() => deployKeysClient.Create("user", null, new NewDeployKey())); await Assert.ThrowsAsync<ArgumentNullException>(() => deployKeysClient.Create("user", "repo", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => deployKeysClient.Create(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => deployKeysClient.Create("", "repo", new NewDeployKey())); await Assert.ThrowsAsync<ArgumentException>(() => deployKeysClient.Create("user", "", new NewDeployKey())); await Assert.ThrowsAsync<ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey())); await Assert.ThrowsAsync<ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey { Key = "ABC123" })); await Assert.ThrowsAsync<ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey { Title = "user@repo" })); }
public void CreatesCorrectUrlWithRepositoryId() { var apiConnection = Substitute.For<IApiConnection>(); var deployKeysClient = new RepositoryDeployKeysClient(apiConnection); var newDeployKey = new NewDeployKey { Key = "ABC123", Title = "user@repo" }; deployKeysClient.Create(1, newDeployKey); apiConnection.Received().Post<DeployKey>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/keys"), newDeployKey); }