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

                await client.GetAll("fake", "repo");

                connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions);
            }
Beispiel #2
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

                await client.GetAll("fake", "repo");

                connection.Received().GetAll <Repository>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions);
            }
Beispiel #3
0
            public async Task RequestsCorrectUrlWithRequestParameters()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

                await client.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers });

                connection.Received().GetAll <Repository>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/forks"),
                    Arg.Is <Dictionary <string, string> >(d => d["sort"] == "stargazers"), Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithRequestParameters()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

                await client.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers });

                connection.Received().GetAll<Repository>(
                    Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"),
                    Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), Args.ApiOptions);
            }
Beispiel #5
0
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

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

                await client.GetAll("fake", "repo", options);

                connection.Received().GetAll <Repository>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/forks"), options);
            }
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

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

                await client.GetAll("fake", "repo", options);

                connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), options);
            }
Beispiel #7
0
            public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryForksClient(connection);

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

                await client.GetAll(1, new RepositoryForksListRequest { Sort = Sort.Stargazers }, options);

                connection.Received().GetAll <Repository>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/forks"),
                    Arg.Is <Dictionary <string, string> >(d => d["sort"] == "stargazers"), options);
            }
Beispiel #8
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryForksClient(Substitute.For <IApiConnection>());

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

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

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "name", new RepositoryForksListRequest()));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null, new RepositoryForksListRequest()));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null));

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", ""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name", ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest()));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", "", new RepositoryForksListRequest()));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest(), ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", "", new RepositoryForksListRequest(), ApiOptions.None));
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryForksClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", (ApiOptions)null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", new RepositoryForksListRequest()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, new RepositoryForksListRequest()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest()));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", new RepositoryForksListRequest()));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest(), ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", new RepositoryForksListRequest(), ApiOptions.None));
            }
            public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryForksClient(connection);

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

                await client.GetAll(1, new RepositoryForksListRequest { Sort = Sort.Stargazers }, options);

                connection.Received().GetAll<Repository>(
                    Arg.Is<Uri>(u => u.ToString() == "repositories/1/forks"),
                    Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), options);
            }