public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var endpoint   = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotificationsClient(connection);

                await client.GetAllForRepository(1);

                connection.Received().GetAll <Notification>(endpoint, Args.ApiOptions);
            }
            public void RequestsCorrectUrl()
            {
                var endpoint   = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotificationsClient(connection);

                client.GetAllForRepository("banana", "split");

                connection.Received().GetAll <Notification>(endpoint);
            }
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new NotificationsClient(connection);

                client.GetAllForRepository("banana", "split");

                connection.Received().GetAll<Notification>(endpoint);
            }
            public async Task RequestsCorrectUrlNotificationRequestWithRepositoryId()
            {
                var endpoint   = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotificationsClient(connection);

                var notificationsRequest = new NotificationsRequest {
                    All = true
                };

                await client.GetAllForRepository(1, notificationsRequest);

                connection.Received().GetAll <Notification>(endpoint, Arg.Is <Dictionary <string, string> >(
                                                                d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"),
                                                            Args.ApiOptions);
            }
            public void RequestsCorrectUrlNotificationRequest()
            {
                var endpoint   = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotificationsClient(connection);

                var notificationsRequest = new NotificationsRequest {
                    All = true
                };

                client.GetAllForRepository("banana", "split", notificationsRequest);

                connection.Received().GetAll <Notification>(endpoint, Arg.Is <Dictionary <string, string> >(
                                                                d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"),
                                                            Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
            {
                var endpoint   = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotificationsClient(connection);

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

                await client.GetAllForRepository(1, options);

                connection.Received().GetAll <Notification>(endpoint, options);
            }
            public void RequestsCorrectUrlWithApiOptions()
            {
                var endpoint   = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotificationsClient(connection);

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

                client.GetAllForRepository("banana", "split", options);

                connection.Received().GetAll <Notification>(endpoint, options);
            }
            public async Task RequestsCorrectUrlNotificationRequestWithApiOptions()
            {
                var endpoint   = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new NotificationsClient(connection);

                var notificationsRequest = new NotificationsRequest {
                    All = true
                };

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

                await client.GetAllForRepository("banana", "split", notificationsRequest, options);

                connection.Received().GetAll <Notification>(endpoint, Arg.Is <Dictionary <string, string> >(
                                                                d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"),
                                                            options);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new NotificationsClient(Substitute.For<IApiConnection>());

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

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (NotificationsRequest)null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, new NotificationsRequest(), null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest()));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest()));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest(), ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest(), ApiOptions.None));
            }
            public async Task RequestsCorrectUrlNotificationRequestWithApiOptionsWithRepositoryId()
            {
                var endpoint = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new NotificationsClient(connection);

                var notificationsRequest = new NotificationsRequest { All = true };

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

                await client.GetAllForRepository(1, notificationsRequest, options);

                connection.Received().GetAll<Notification>(endpoint, Arg.Is<Dictionary<string, string>>(
                        d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"),
                    options);
            }
            public async Task RequestsCorrectUrlNotificationRequest()
            {
                var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new NotificationsClient(connection);

                var notificationsRequest = new NotificationsRequest { All = true };

                await client.GetAllForRepository("banana", "split", notificationsRequest);

                connection.Received().GetAll<Notification>(endpoint, Arg.Is<Dictionary<string, string>>(
                        d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"),
                    Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
            {
                var endpoint = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new NotificationsClient(connection);

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

                await client.GetAllForRepository(1, options);

                connection.Received().GetAll<Notification>(endpoint, options);
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var endpoint = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new NotificationsClient(connection);

                await client.GetAllForRepository(1);

                connection.Received().GetAll<Notification>(endpoint, Args.ApiOptions);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new NotificationsClient(Substitute.For <IApiConnection>());

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(1, new NotificationsRequest(), null));

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

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

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

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

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

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

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest(), ApiOptions.None));
            }
            public void RequestsCorrectUrlWithApiOptions()
            {
                var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new NotificationsClient(connection);

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

                client.GetAllForRepository("banana", "split", options);

                connection.Received().GetAll<Notification>(endpoint, options);
            }