Exemple #1
0
            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);
            }
Exemple #3
0
            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);
            }
Exemple #4
0
            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);
            }