public void EnsuresNonNullArguments()
            {
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => deployKeysClient.GetAll(null, "repo"));
                Assert.Throws<ArgumentException>(() => deployKeysClient.GetAll("", "repo"));
                Assert.Throws<ArgumentNullException>(() => deployKeysClient.GetAll("user", null));
                Assert.Throws<ArgumentException>(() => deployKeysClient.GetAll("user", ""));
            }
            public void RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(gitHubClient);

                deployKeysClient.GetAll("user", "repo");

                gitHubClient.Connection.Received(1).Get<List<DeployKey>>(
                    new Uri("repos/user/repo/keys", UriKind.Relative), Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null);
            }
            public void CallsIntoClient()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(githubClient);

                deployKeysClient.GetAll("user", "repo");

                githubClient.Connection.Received(1).Get<List<DeployKey>>(
                    new Uri("repos/user/repo/keys", UriKind.Relative), null, null);
            }
            public void RequestsCorrectUrlWithApiOptions()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(gitHubClient);
                var expectedUrl = string.Format("repos/{0}/{1}/keys", "user", "repo");

                // all properties are setted => only 2 options (StartPage, PageSize) in dictionary
                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                deployKeysClient.GetAll("user", "repo", options);
                gitHubClient.Connection.Received(1)
                    .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                        Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2),
                        null);

                // StartPage is setted => only 1 option (StartPage) in dictionary
                options = new ApiOptions
                {
                    StartPage = 1
                };

                deployKeysClient.GetAll("user", "repo", options);
                gitHubClient.Connection.Received(1)
                    .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                        Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1),
                        null);

                // PageCount is setted => none of options in dictionary
                options = new ApiOptions
                {
                    PageCount = 1
                };

                deployKeysClient.GetAll("user", "repo", options);
                gitHubClient.Connection.Received(1)
                    .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                        Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0),
                        null);
            }