rewrite the setup of responses to use a standard helper function (#2177)

This commit is contained in:
Brendan Forster
2020-04-14 11:30:15 -03:00
committed by GitHub
parent 69d118230d
commit 287861e4a7
41 changed files with 390 additions and 448 deletions
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NSubstitute;
@@ -7,6 +8,8 @@ using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservableIssueTimelineClientTests
@@ -33,10 +36,8 @@ namespace Octokit.Tests.Reactive
var client = new ObservableIssueTimelineClient(gitHubClient);
IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
CreateResponse(HttpStatusCode.OK),
result);
gitHubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Args.EmptyDictionary, "application/vnd.github.mockingbird-preview+json")
.Returns(Task.FromResult(response));
@@ -58,11 +59,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssueTimelineClient(gitHubClient);
IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 1), "application/vnd.github.mockingbird-preview+json")
.Returns(Task.FromResult(response));
@@ -83,11 +80,7 @@ namespace Octokit.Tests.Reactive
var githubClient = new GitHubClient(connection);
var client = new ObservableIssueTimelineClient(githubClient);
IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(CreateResponse(HttpStatusCode.OK), result);
githubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Args.EmptyDictionary, "application/vnd.github.mockingbird-preview+json")
.Returns(Task.FromResult(response));
@@ -108,11 +101,7 @@ namespace Octokit.Tests.Reactive
var githubClient = new GitHubClient(connection);
var client = new ObservableIssueTimelineClient(githubClient);
IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(CreateResponse(HttpStatusCode.OK), result);
githubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 1), "application/vnd.github.mockingbird-preview+json")
.Returns(Task.FromResult(response));
@@ -1,13 +1,16 @@
using NSubstitute;
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NSubstitute;
using Octokit;
using Octokit.Internal;
using Octokit.Reactive;
using System;
using System.Collections.Generic;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;
using static Octokit.Internal.TestSetup;
public class ObservableIssuesClientTests
{
public class TheGetMethod
@@ -288,7 +291,7 @@ public class ObservableIssuesClientTests
);
var lastPageResponse = new ApiResponse<List<Issue>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Issue>
{
CreateIssue(7)
@@ -364,7 +367,7 @@ public class ObservableIssuesClientTests
);
var lastPageResponse = new ApiResponse<List<Issue>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Issue>
{
CreateIssue(7)
@@ -451,7 +454,7 @@ public class ObservableIssuesClientTests
);
var lastPageResponse = new ApiResponse<List<Issue>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Issue>
{
CreateIssue(7)
@@ -524,7 +527,7 @@ public class ObservableIssuesClientTests
);
var lastPageResponse = new ApiResponse<List<Issue>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Issue>
{
CreateIssue(7)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NSubstitute;
@@ -7,6 +8,8 @@ using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservableIssuesEventsClientTests
@@ -32,11 +35,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesEventsClient(gitHubClient);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null)
.Returns(Task.FromResult(response));
@@ -55,11 +54,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesEventsClient(gitHubClient);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null)
.Returns(Task.FromResult(response));
@@ -85,11 +80,7 @@ namespace Octokit.Tests.Reactive
PageSize = 1
};
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
.Returns(Task.FromResult(response));
@@ -116,10 +107,7 @@ namespace Octokit.Tests.Reactive
};
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()),
}, result);
CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
.Returns(Task.FromResult(response));
@@ -160,11 +148,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesEventsClient(gitHubClient);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag1", new RateLimit()),
}, result);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null)
.Returns(Task.FromResult(response));
@@ -183,11 +167,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = new GitHubClient(connection);
var client = new ObservableIssuesEventsClient(gitHubClient);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag1", new RateLimit()),
}, result);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null)
.Returns(Task.FromResult(response));
@@ -213,11 +193,7 @@ namespace Octokit.Tests.Reactive
PageSize = 1
};
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag1", new RateLimit()),
}, result);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
.Returns(Task.FromResult(response));
@@ -243,11 +219,7 @@ namespace Octokit.Tests.Reactive
PageSize = 1
};
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(
new Response
{
ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag1", new RateLimit()),
}, result);
IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result);
gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null)
.Returns(Task.FromResult(response));
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
@@ -8,6 +9,8 @@ using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservableMilestonesClientTests
@@ -240,7 +243,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<Milestone>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Milestone>
{
new Milestone(7)
@@ -293,7 +296,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<Milestone>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit(new Dictionary<string, string>())) },
CreateResponse(HttpStatusCode.OK),
new List<Milestone>
{
new Milestone(7)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NSubstitute;
@@ -7,6 +8,8 @@ using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservablePullRequestReviewCommentsClientTests
@@ -117,7 +120,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7)
@@ -172,7 +175,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7)
@@ -335,7 +338,7 @@ namespace Octokit.Tests.Reactive
});
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7),
@@ -419,7 +422,7 @@ namespace Octokit.Tests.Reactive
});
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7),
@@ -560,7 +563,7 @@ namespace Octokit.Tests.Reactive
});
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7),
@@ -632,7 +635,7 @@ namespace Octokit.Tests.Reactive
});
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7),
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NSubstitute;
@@ -7,6 +8,8 @@ using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservablePullRequestReviewsClientTests
@@ -117,7 +120,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequestReview>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReview>
{
new PullRequestReview(7)
@@ -172,7 +175,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequestReview>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReview>
{
new PullRequestReview(7)
@@ -512,7 +515,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7)
@@ -567,7 +570,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestReviewComment>
{
new PullRequestReviewComment(7)
@@ -1,14 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
using NSubstitute;
using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservablePullRequestsClientTests
@@ -202,7 +204,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequest>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequest>
{
new PullRequest(7)
@@ -255,7 +257,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequest>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequest>
{
new PullRequest(7)
@@ -308,7 +310,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequest>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequest>
{
new PullRequest(7)
@@ -377,7 +379,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<PullRequest>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequest>
{
new PullRequest(7)
@@ -635,7 +637,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
IApiResponse<List<PullRequestCommit>> response = new ApiResponse<List<PullRequestCommit>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestCommit> { commit }
);
connection.Get<List<PullRequestCommit>>(Args.Uri, null, null)
@@ -659,7 +661,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
IApiResponse<List<PullRequestCommit>> response = new ApiResponse<List<PullRequestCommit>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestCommit> { commit }
);
connection.Get<List<PullRequestCommit>>(Args.Uri, null, null)
@@ -699,7 +701,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
IApiResponse<List<PullRequestFile>> response = new ApiResponse<List<PullRequestFile>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestFile> { file }
);
connection.Get<List<PullRequestFile>>(Args.Uri, null, null)
@@ -723,7 +725,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
IApiResponse<List<PullRequestFile>> response = new ApiResponse<List<PullRequestFile>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<PullRequestFile> { file }
);
connection.Get<List<PullRequestFile>>(Args.Uri, null, null)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Threading.Tasks;
using NSubstitute;
@@ -7,6 +8,8 @@ using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservableRepositoriesClientTests
@@ -153,7 +156,7 @@ namespace Octokit.Tests.Reactive
public async Task IsALukeWarmObservable()
{
var repository = new Repository();
var response = Task.FromResult<IApiResponse<Repository>>(new ApiResponse<Repository>(new Response(), repository));
var response = Task.FromResult<IApiResponse<Repository>>(new ApiResponse<Repository>(CreateResponse(HttpStatusCode.OK), repository));
var connection = Substitute.For<IConnection>();
connection.Get<Repository>(Args.Uri, null, Args.AnyAcceptHeaders).Returns(response);
var gitHubClient = new GitHubClient(connection);
@@ -178,7 +181,7 @@ namespace Octokit.Tests.Reactive
public async Task IsALukeWarmObservableWithRepositoryId()
{
var repository = new Repository();
var response = Task.FromResult<IApiResponse<Repository>>(new ApiResponse<Repository>(new Response(), repository));
var response = Task.FromResult<IApiResponse<Repository>>(new ApiResponse<Repository>(CreateResponse(HttpStatusCode.OK), repository));
var connection = Substitute.For<IConnection>();
connection.Get<Repository>(Args.Uri, null, Args.AnyAcceptHeaders).Returns(response);
var gitHubClient = new GitHubClient(connection);
@@ -238,7 +241,7 @@ namespace Octokit.Tests.Reactive
new Repository(6)
});
var lastPageResponse = new ApiResponse<List<Repository>>(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Repository>
{
new Repository(7)
@@ -301,7 +304,7 @@ namespace Octokit.Tests.Reactive
);
var lastPageResponse = new ApiResponse<List<Repository>>
(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Repository>
{
new Repository(8)
@@ -358,7 +361,7 @@ namespace Octokit.Tests.Reactive
});
IApiResponse<List<Repository>> lastPageResponse = new ApiResponse<List<Repository>>(
new Response(),
CreateResponse(HttpStatusCode.OK),
new List<Repository>
{
new Repository(370)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -8,6 +9,8 @@ using Octokit.Internal;
using Octokit.Reactive;
using Xunit;
using static Octokit.Internal.TestSetup;
namespace Octokit.Tests.Reactive
{
public class ObservableRepositoryContentsClientTests
@@ -43,7 +46,7 @@ namespace Octokit.Tests.Reactive
gitHubClient.Repository.Content.GetReadme("fake", "repo").Returns(Task.FromResult(readmeFake));
IApiResponse<string> apiResponse = new ApiResponse<string>(new Response(), "<html>README</html>");
IApiResponse<string> apiResponse = new ApiResponse<string>(CreateResponse(HttpStatusCode.OK), "<html>README</html>");
gitHubClient.Connection.GetHtml(Args.Uri, null)
.Returns(Task.FromResult(apiResponse));
@@ -79,7 +82,7 @@ namespace Octokit.Tests.Reactive
gitHubClient.Repository.Content.GetReadme(1).Returns(Task.FromResult(readmeFake));
IApiResponse<string> apiResponse = new ApiResponse<string>(new Response(), "<html>README</html>");
IApiResponse<string> apiResponse = new ApiResponse<string>(CreateResponse(HttpStatusCode.OK), "<html>README</html>");
gitHubClient.Connection.GetHtml(Args.Uri, null)
.Returns(Task.FromResult(apiResponse));
@@ -118,7 +121,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<string> apiResponse = new ApiResponse<string>(new Response(), "<html>README</html>");
IApiResponse<string> apiResponse = new ApiResponse<string>(CreateResponse(HttpStatusCode.OK), "<html>README</html>");
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult(apiResponse));
@@ -134,7 +137,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<string> apiResponse = new ApiResponse<string>(new Response(), "<html>README</html>");
IApiResponse<string> apiResponse = new ApiResponse<string>(CreateResponse(HttpStatusCode.OK), "<html>README</html>");
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult(apiResponse));
@@ -168,11 +171,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -191,11 +190,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -214,11 +209,8 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -236,11 +228,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -284,11 +272,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<byte[]> response = new ApiResponse<byte[]>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<byte[]> response = new ApiResponse<byte[]>(CreateResponse(HttpStatusCode.OK), result);
connection.GetRaw(Args.Uri, default).Returns(response);
var rawContent = await contentsClient.GetRawContent("fake", "repo", "path/to/file.txt");
@@ -323,11 +307,8 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -345,11 +326,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -367,11 +344,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -389,11 +362,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result);
connection.Get<List<RepositoryContent>>(Args.Uri, null, null)
.Returns(Task.FromResult(response));
@@ -445,11 +414,7 @@ namespace Octokit.Tests.Reactive
var connection = Substitute.For<IConnection>();
var gitHubClient = new GitHubClient(connection);
var contentsClient = new ObservableRepositoryContentsClient(gitHubClient);
IApiResponse<byte[]> response = new ApiResponse<byte[]>
(
new Response { ApiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()) },
result
);
IApiResponse<byte[]> response = new ApiResponse<byte[]>(CreateResponse(HttpStatusCode.OK), result);
connection.GetRaw(Args.Uri, default).Returns(response);
var rawContent = await contentsClient.GetRawContentByRef("fake", "repo", "path/to/file.txt", "reference");
@@ -977,4 +942,4 @@ namespace Octokit.Tests.Reactive
}
}
}
}
}