Пример #1
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new ReleasesClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllAssets(null, "name", 1));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllAssets("", "name", 1));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllAssets("owner", null, 1));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllAssets("owner", "", 1));
            }
Пример #2
0
            public void RequestsTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ReleasesClient(connection);

                client.GetAllAssets("fake", "repo", 1);

                connection.Received().GetAll <ReleaseAsset>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/1/assets"),
                                                            null,
                                                            "application/vnd.github.v3");
            }
Пример #3
0
            public async Task RequestsTheCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ReleasesClient(connection);

                await client.GetAllAssets(1, 1);

                connection.Received().GetAll <ReleaseAsset>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/releases/1/assets"),
                                                            null,
                                                            "application/vnd.github.v3",
                                                            Args.ApiOptions);
            }
Пример #4
0
            public async Task RequestsTheCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ReleasesClient(connection);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize  = 1
                };

                await client.GetAllAssets("fake", "repo", 1, options);

                connection.Received().GetAll <ReleaseAsset>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/1/assets"),
                    null,
                    "application/vnd.github.v3", options);
            }
Пример #5
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new ReleasesClient(Substitute.For<IApiConnection>());
                
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAssets(null, "name", 1));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAssets("owner", null, 1));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAssets(null, "name", 1, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAssets("owner", null, 1, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAssets("owner", "name", 1, null));

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

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAssets("", "name", 1));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAssets("owner", "", 1));
            }
Пример #6
0
            public async Task RequestsTheCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new ReleasesClient(connection);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                await client.GetAllAssets(1, 1, options);

                connection.Received().GetAll<ReleaseAsset>(
                    Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases/1/assets"),
                    null,
                    "application/vnd.github.v3", options);
            }
Пример #7
0
            public async Task RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new ReleasesClient(connection);

                await client.GetAllAssets("fake", "repo", 1);

                connection.Received().GetAll<ReleaseAsset>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/1/assets"),
                    null,
                    "application/vnd.github.v3",
                    Args.ApiOptions);
            }