Ejemplo n.º 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);
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 4
0
        public async Task EnsuresNonNullArguments()
        {
            var client = new TagsClient(Substitute.For<IApiConnection>());

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

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

            await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", "reference"));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", "reference"));
            await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "name", ""));

            await Assert.ThrowsAsync<ArgumentException>(() => client.Get(1, ""));
        }