From 49efc193361f6c60f81072e193b33d05e88571db Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 24 Feb 2019 13:38:36 +1000 Subject: [PATCH] Fix the broken tests --- .../Clients/IObservableMigrationsClient.cs | 4 ++-- .../Clients/ObservableMigrationsClient.cs | 11 ++++++++--- .../Reactive/ObservableMigrationsClientTests.cs | 7 +++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableMigrationsClient.cs b/Octokit.Reactive/Clients/IObservableMigrationsClient.cs index 263950980c..f95c7861bd 100644 --- a/Octokit.Reactive/Clients/IObservableMigrationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableMigrationsClient.cs @@ -36,7 +36,7 @@ IObservable Start( /// /// The organization of which to list migrations. /// List of most recent s. - IObservable> GetAll( + IObservable GetAll( string org); /// @@ -48,7 +48,7 @@ IObservable> GetAll( /// The organization of which to list migrations. /// Options for changing the API response /// List of most recent s. - IObservable> GetAll( + IObservable GetAll( string org, ApiOptions options); diff --git a/Octokit.Reactive/Clients/ObservableMigrationsClient.cs b/Octokit.Reactive/Clients/ObservableMigrationsClient.cs index fde1f0ea1b..39ce9aecf5 100644 --- a/Octokit.Reactive/Clients/ObservableMigrationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableMigrationsClient.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Reactive; using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; namespace Octokit.Reactive { @@ -15,6 +16,7 @@ namespace Octokit.Reactive public class ObservableMigrationsClient : IObservableMigrationsClient { private readonly IMigrationsClient _client; + private readonly IConnection _connection; /// /// Instantiates a GitHub Migrations API client. @@ -25,6 +27,7 @@ public ObservableMigrationsClient(IGitHubClient client) Ensure.ArgumentNotNull(client, nameof(client)); _client = client.Migration.Migrations; + _connection = client.Connection; } /// @@ -50,14 +53,16 @@ public IObservable Start(string org, StartMigrationRequest migration) /// /// The organization of which to list migrations. /// List of most recent s. - public IObservable> GetAll(string org) + public IObservable GetAll(string org) { return GetAll(org, ApiOptions.None); } - public IObservable> GetAll(string org, ApiOptions options) + public IObservable GetAll(string org, ApiOptions options) { - return _client.GetAll(org, options).ToObservable(); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.EnterpriseMigrations(org), null, AcceptHeaders.MigrationsApiPreview, options); } /// diff --git a/Octokit.Tests/Reactive/ObservableMigrationsClientTests.cs b/Octokit.Tests/Reactive/ObservableMigrationsClientTests.cs index bc4804c674..d06bb6c86e 100644 --- a/Octokit.Tests/Reactive/ObservableMigrationsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableMigrationsClientTests.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Linq; using NSubstitute; using Octokit.Reactive; +using Octokit.Reactive.Internal; using Xunit; namespace Octokit.Tests.Reactive @@ -46,7 +48,7 @@ public void CallsIntoClient() var client = new ObservableMigrationsClient(github); client.GetAll("fake"); - github.Migration.Migrations.Received(1).GetAll("fake", Args.ApiOptions); + github.Received().Migration.Migrations.GetAll("fake", Args.ApiOptions); } [Fact] @@ -61,7 +63,8 @@ public void CallsIntoClientApiOptions() }; client.GetAll("fake", options); - github.Migration.Migrations.Received(1).GetAll("fake", options); + + github.Received().Migration.Migrations.GetAll("fake", options); } }