예제 #1
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new IssueCommentsClient(connection);

            await AssertEx.Throws <ArgumentNullException>(async() => await client.Update(null, "name", 42, "title"));

            await AssertEx.Throws <ArgumentException>(async() => await client.Update("", "name", 42, "x"));

            await AssertEx.Throws <ArgumentNullException>(async() => await client.Update("owner", null, 42, "x"));

            await AssertEx.Throws <ArgumentException>(async() => await client.Update("owner", "", 42, "x"));

            await AssertEx.Throws <ArgumentNullException>(async() => await client.Update("owner", "name", 42, null));
        }
예제 #2
0
        public void PostsToCorrectUrl()
        {
            const string issueCommentUpdate = "Worthwhile update";
            var          connection         = Substitute.For <IApiConnection>();
            var          client             = new IssueCommentsClient(connection);

            client.Update("fake", "repo", 42, issueCommentUpdate);

            connection.Received().Patch <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any <object>());
        }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssueCommentsClient(connection);

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(null, "name", 42, "x"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("owner", null, 42, "x"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("owner", "name", 42, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(1, 42, null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Update("", "name", 42, "x"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Update("owner", "", 42, "x"));
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssueCommentsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "name", 42, "x"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", null, 42, "x"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", 42, null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(1, 42, null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "name", 42, "x"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", 42, "x"));
            }
            public void PostsToCorrectUrlWithRepositoryId()
            {
                const string issueCommentUpdate = "Worthwhile update";
                var connection = Substitute.For<IApiConnection>();
                var client = new IssueCommentsClient(connection);

                client.Update(1, 42, issueCommentUpdate);

                connection.Received().Patch<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42"), Arg.Any<object>());
            }