コード例 #1
0
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new TagsClient(connection);

            client.Get("owner", "repo", "reference");

            connection.Received().Get<GitTag>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/tags/reference"), null);
        }
コード例 #2
0
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new TagsClient(connection);

            await client.Get(1, "reference");

            connection.Received().Get<GitTag>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/tags/reference"), null, "application/vnd.github.cryptographer-preview+sha");
        }
コード例 #3
0
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new TagsClient(connection);

            await client.Get(1, "reference");

            connection.Received().Get<GitTag>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/git/tags/reference"));
        }
コード例 #4
0
        public async Task EnsuresNonNullArguments()
        {
            var client = new TagsClient(Substitute.For<IApiConnection>());

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", new NewTag()));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, new NewTag()));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewTag()));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewTag()));
        }
コード例 #5
0
        public void PostsToTheCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new TagsClient(connection);

            client.Create("owner", "repo", new NewTag { Type = TaggedType.Tree });

            connection.Received().Post<GitTag>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/tags"),
                                            Arg.Is<NewTag>(nt => nt.Type == TaggedType.Tree));
        }
コード例 #6
0
        public async Task EnsuresNonNullArguments()
        {
            var client = new TagsClient(Substitute.For<IApiConnection>());

            await AssertEx.Throws<ArgumentNullException>(async () => await client.Get(null, "name", "reference"));
            await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", null, "reference"));
            await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", "name", null));
            await AssertEx.Throws<ArgumentException>(async () => await client.Get("", "name", "reference"));
            await AssertEx.Throws<ArgumentException>(async () => await client.Get("owner", "", "reference"));
            await AssertEx.Throws<ArgumentException>(async () => await client.Get("owner", "name", ""));
        }