public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssuesClient(connection);

                client.GetAllForOrganization("fake");

                connection.Received().GetAll <Issue>(Arg.Is <Uri>(u => u.ToString() == "orgs/fake/issues"),
                                                     Arg.Any <Dictionary <string, string> >(),
                                                     Args.ApiOptions);
            }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssuesClient(connection);

                await client.GetAllForOrganization("fake");

                connection.Received().GetAll <Issue>(Arg.Is <Uri>(u => u.ToString() == "orgs/fake/issues"),
                                                     Arg.Any <Dictionary <string, string> >(),
                                                     "application/vnd.github.squirrel-girl-preview+json",
                                                     Args.ApiOptions);
            }
            public void SendsAppropriateParameters()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssuesClient(connection);

                client.GetAllForOrganization("fake", new RepositoryIssueRequest
                {
                    SortDirection = SortDirection.Ascending
                });

                connection.Received().GetAll <Issue>(Arg.Is <Uri>(u => u.ToString() == "orgs/fake/issues"),
                                                     Arg.Is <Dictionary <string, string> >(d => d.Count == 4 &&
                                                                                           d["state"] == "open" &&
                                                                                           d["direction"] == "asc" &&
                                                                                           d["sort"] == "created" &&
                                                                                           d["filter"] == "assigned"),
                                                     Args.ApiOptions);
            }
            public async Task EnsuresArgumentsNotNull()
            {
                var client = new IssuesClient(Substitute.For <IApiConnection>());

                var options = new ApiOptions();
                var request = new RepositoryIssueRequest();

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null, options));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null, request));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization(null, request, options));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization(""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization("", options));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization("", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForOrganization("", request, options));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", (ApiOptions)null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", (IssueRequest)null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", null, options));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForOrganization("org", request, null));
            }
            public void SendsAppropriateParameters()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssuesClient(connection);

                client.GetAllForOrganization("fake", new RepositoryIssueRequest
                {
                    SortDirection = SortDirection.Ascending
                });

                connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/issues"),
                    Arg.Is<Dictionary<string, string>>(d => d.Count == 4
                        && d["state"] == "open"
                        && d["direction"] == "asc"
                        && d["sort"] == "created"
                        && d["filter"] == "assigned"),
                    Args.ApiOptions);
            }
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssuesClient(connection);

                client.GetAllForOrganization("fake");

                connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/issues"),
                    Arg.Any<Dictionary<string, string>>(),
                    Args.ApiOptions);
            }
            public async Task EnsuresArgumentsNotNull()
            {
                var client = new IssuesClient(Substitute.For<IApiConnection>());

                var options = new ApiOptions();
                var request = new RepositoryIssueRequest();

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, options));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, request));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, request, options));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization(""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", options));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", request));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", request, options));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", (ApiOptions)null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", (IssueRequest)null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", null, options));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", request, null));
            }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssuesClient(connection);

                await client.GetAllForOrganization("fake");

                connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/issues"),
                    Arg.Any<Dictionary<string, string>>(),
                    "application/vnd.github.squirrel-girl-preview",
                    Args.ApiOptions);
            }