public async Task IsALukeWarmObservableWithRepositoryId()
            {
                var repository = new Repository();
                var response   = Task.Factory.StartNew <IApiResponse <Repository> >(() =>
                                                                                    new ApiResponse <Repository>(new Response(), repository));
                var connection = Substitute.For <IConnection>();

                connection.Get <Repository>(Args.Uri, null, Args.AnyAcceptHeaders).Returns(response);
                var gitHubClient = new GitHubClient(connection);
                var client       = new ObservableRepositoriesClient(gitHubClient);
                var observable   = client.Get(1);

                connection.Received(1).Get <Repository>(Args.Uri, null, Args.AnyAcceptHeaders);

                var result = await observable;

                connection.Received(1).Get <Repository>(Args.Uri, null, Args.AnyAcceptHeaders);
                var result2 = await observable;

                // TODO: If we change this to a warm observable, we'll need to change this to Received(2)
                connection.Received(1).Get <Repository>(Args.Uri, null, Args.AnyAcceptHeaders);

                Assert.Same(repository, result);
                Assert.Same(repository, result2);
            }
            public async Task IsALukeWarmObservable()
            {
                var repository = new Repository();
                var response   = Task.Factory.StartNew <IResponse <Repository> >(() =>
                                                                                 new ApiResponse <Repository> {
                    BodyAsObject = repository
                });
                var connection = Substitute.For <IConnection>();

                connection.GetAsync <Repository>(Args.Uri, null, null).Returns(response);
                var gitHubClient = new GitHubClient(connection);
                var client       = new ObservableRepositoriesClient(gitHubClient);
                var observable   = client.Get("stark", "ned");

                connection.Received(1).GetAsync <Repository>(Args.Uri, null, null);

                var result = await observable;

                connection.Received(1).GetAsync <Repository>(Args.Uri, null, null);
                var result2 = await observable;

                // TODO: If we change this to a warm observable, we'll need to change this to Received(2)
                connection.Received(1).GetAsync <Repository>(Args.Uri, null, null);

                Assert.Same(repository, result);
                Assert.Same(repository, result2);
            }
Beispiel #3
0
            public async Task IsALukeWarmObservable()
            {
                var repository = new Repository();
                var response   = Task.Factory.StartNew <IApiResponse <Repository> >(() =>
                                                                                    new ApiResponse <Repository>(new Response(), repository));
                var connection = Substitute.For <IConnection>();

                connection.Get <Repository>(Args.Uri, null, "application/vnd.github.polaris-preview+json").Returns(response);
                var gitHubClient = new GitHubClient(connection);
                var client       = new ObservableRepositoriesClient(gitHubClient);
                var observable   = client.Get("stark", "ned");

                connection.Received(1).Get <Repository>(Args.Uri, null, "application/vnd.github.polaris-preview+json");

                var result = await observable;

                connection.Received(1).Get <Repository>(Args.Uri, null, "application/vnd.github.polaris-preview+json");
                var result2 = await observable;

                // TODO: If we change this to a warm observable, we'll need to change this to Received(2)
                connection.Received(1).Get <Repository>(Args.Uri, null, "application/vnd.github.polaris-preview+json");

                Assert.Same(repository, result);
                Assert.Same(repository, result2);
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoriesClient(gitHubClient);

                await client.Get(1);

                gitHubClient.Repository.Get(1);
            }
            public async Task RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoriesClient(gitHubClient);

                await client.Get("owner", "name");

                gitHubClient.Received().Repository.Get("owner", "name");
            }
Beispiel #6
0
            public async Task ReturnsSpecifiedRepository()
            {
                var github = Helper.GetAuthenticatedClient();

                var client      = new ObservableRepositoriesClient(github);
                var observable  = client.Get("haacked", "seegit");
                var repository  = await observable;
                var repository2 = await observable;

                Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl);
                Assert.False(repository.Private);
                Assert.False(repository.Fork);
                Assert.Equal("https://github.com/Haacked/SeeGit.git", repository2.CloneUrl);
                Assert.False(repository2.Private);
                Assert.False(repository2.Fork);
            }
Beispiel #7
0
            public async Task ReturnsSpecifiedRepository()
            {
                var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
                {
                    Credentials = Helper.Credentials
                };
                var client      = new ObservableRepositoriesClient(github);
                var observable  = client.Get("haacked", "seegit");
                var repository  = await observable;
                var repository2 = await observable;

                Assert.Equal("https://github.com/Haacked/SeeGit.git", repository.CloneUrl);
                Assert.False(repository.Private);
                Assert.False(repository.Fork);
                Assert.Equal("https://github.com/Haacked/SeeGit.git", repository2.CloneUrl);
                Assert.False(repository2.Private);
                Assert.False(repository2.Fork);
            }