public async Task SurfacesAuthorizationExceptionWhenSpecifyingCollaboratorRequest()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                connection.Connection.Put <object>(Arg.Any <Uri>(), Arg.Any <object>()).ThrowsAsync(new AuthorizationException());

                await Assert.ThrowsAsync <AuthorizationException>(() => client.Add("owner", "test", "user1", new CollaboratorRequest(Permission.Pull)));

                await Assert.ThrowsAsync <AuthorizationException>(() => client.Add(1, "user1", new CollaboratorRequest(Permission.Pull)));
            }
            public async Task SurfacesAuthorizationException()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                connection.Put(Arg.Any <Uri>()).Returns(x => { throw new AuthorizationException(); });

                await Assert.ThrowsAsync <AuthorizationException>(() => client.Add("owner", "test", "user1"));

                await Assert.ThrowsAsync <AuthorizationException>(() => client.Add(1, "user1"));
            }
Beispiel #3
0
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                client.Add("owner", "test", "user1");
                connection.Received().Put(Arg.Is <Uri>(u => u.ToString() == "repos/owner/test/collaborators/user1"));
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepoCollaboratorsClient(connection);

                client.Add(1, "user1");
                connection.Received().Put(Arg.Is <Uri>(u => u.ToString() == "repositories/1/collaborators/user1"));
            }
Beispiel #5
0
            public void EnsuresNonNullArguments()
            {
                var client = new RepoCollaboratorsClient(Substitute.For <IApiConnection>());

                Assert.Throws <ArgumentNullException>(() => client.Add(null, "test", "user1"));
                Assert.Throws <ArgumentException>(() => client.Add("", "test", "user1"));
                Assert.Throws <ArgumentNullException>(() => client.Add("owner", null, "user1"));
                Assert.Throws <ArgumentException>(() => client.Add("owner", "", "user1"));
                Assert.Throws <ArgumentException>(() => client.Add("owner", "test", ""));
                Assert.Throws <ArgumentNullException>(() => client.Add("owner", "test", null));
            }
            public void EnsuresNonNullArguments()
            {
                var client = new RepoCollaboratorsClient(Substitute.For<IApiConnection>());

                Assert.Throws<ArgumentNullException>(() => client.Add(null, "test","user1"));
                Assert.Throws<ArgumentException>(() => client.Add("", "test", "user1"));
                Assert.Throws<ArgumentNullException>(() => client.Add("owner", null, "user1"));
                Assert.Throws<ArgumentException>(() => client.Add("owner", "", "user1"));
                Assert.Throws<ArgumentException>(() => client.Add("owner", "test", ""));
                Assert.Throws<ArgumentNullException>(() => client.Add("owner", "test", null));
            }
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepoCollaboratorsClient(connection);

                client.Add("owner", "test", "user1");
                connection.Received().Put(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators/user1"));
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepoCollaboratorsClient(connection);

                client.Add(1, "user1");
                connection.Received().Put(Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators/user1"));
            }