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));