PageRenderTime 53ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/Octokit.Tests/Clients/StarredClientTests.cs

https://gitlab.com/WoomyNightClub/GitHub-API-.NET
C# | 572 lines | 455 code | 117 blank | 0 comment | 27 complexity | 75ccff12a75d3c5d025745222eb6e64f MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net;
  4. using System.Threading.Tasks;
  5. using NSubstitute;
  6. using Octokit.Internal;
  7. using Xunit;
  8. namespace Octokit.Tests.Clients
  9. {
  10. public class StarredClientTests
  11. {
  12. public class TheCtor
  13. {
  14. [Fact]
  15. public void EnsuresNonNullArguments()
  16. {
  17. Assert.Throws<ArgumentNullException>(() => new StarredClient(null));
  18. }
  19. }
  20. public class TheGetAllForCurrentMethod
  21. {
  22. [Fact]
  23. public async Task RequestsCorrectUrl()
  24. {
  25. var endpoint = new Uri("user/starred", UriKind.Relative);
  26. var connection = Substitute.For<IApiConnection>();
  27. var client = new StarredClient(connection);
  28. await client.GetAllForCurrent();
  29. connection.Received().GetAll<Repository>(endpoint, Args.ApiOptions);
  30. }
  31. [Fact]
  32. public async Task RequestsCorrectUrlWithApiOptions()
  33. {
  34. var endpoint = new Uri("user/starred", UriKind.Relative);
  35. var connection = Substitute.For<IApiConnection>();
  36. var client = new StarredClient(connection);
  37. var options = new ApiOptions
  38. {
  39. PageCount = 1,
  40. StartPage = 1,
  41. PageSize = 1
  42. };
  43. await client.GetAllForCurrent(options);
  44. connection.Received().GetAll<Repository>(endpoint, options);
  45. }
  46. [Fact]
  47. public async Task RequestsCorrectUrlParametrized()
  48. {
  49. var endpoint = new Uri("user/starred", UriKind.Relative);
  50. var connection = Substitute.For<IApiConnection>();
  51. var client = new StarredClient(connection);
  52. var request = new StarredRequest { SortDirection = SortDirection.Ascending };
  53. await client.GetAllForCurrent(request);
  54. connection.Received().GetAll<Repository>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"),
  55. Args.ApiOptions);
  56. }
  57. [Fact]
  58. public async Task RequestsCorrectUrlParametrizedWithApiOptions()
  59. {
  60. var endpoint = new Uri("user/starred", UriKind.Relative);
  61. var connection = Substitute.For<IApiConnection>();
  62. var client = new StarredClient(connection);
  63. var options = new ApiOptions
  64. {
  65. PageCount = 1,
  66. StartPage = 1,
  67. PageSize = 1
  68. };
  69. var request = new StarredRequest { SortDirection = SortDirection.Ascending };
  70. await client.GetAllForCurrent(request, options);
  71. connection.Received().GetAll<Repository>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), options);
  72. }
  73. [Fact]
  74. public async Task RequestsCorrectUrlWithTimestamps()
  75. {
  76. var endpoint = new Uri("user/starred", UriKind.Relative);
  77. var connection = Substitute.For<IApiConnection>();
  78. var client = new StarredClient(connection);
  79. await client.GetAllForCurrentWithTimestamps();
  80. connection.Received().GetAll<RepositoryStar>(endpoint, null, "application/vnd.github.v3.star+json", Args.ApiOptions);
  81. }
  82. [Fact]
  83. public async Task RequestsCorrectUrlWithTimestampsWithApiOptions()
  84. {
  85. var endpoint = new Uri("user/starred", UriKind.Relative);
  86. var connection = Substitute.For<IApiConnection>();
  87. var client = new StarredClient(connection);
  88. var options = new ApiOptions
  89. {
  90. PageCount = 1,
  91. StartPage = 1,
  92. PageSize = 1
  93. };
  94. await client.GetAllForCurrentWithTimestamps(options);
  95. connection.Received().GetAll<RepositoryStar>(endpoint, null, "application/vnd.github.v3.star+json", options);
  96. }
  97. [Fact]
  98. public async Task RequestsCorrectUrlWithTimestampsParametrized()
  99. {
  100. var endpoint = new Uri("user/starred", UriKind.Relative);
  101. var connection = Substitute.For<IApiConnection>();
  102. var client = new StarredClient(connection);
  103. var request = new StarredRequest { SortDirection = SortDirection.Ascending };
  104. await client.GetAllForCurrentWithTimestamps(request);
  105. connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"),
  106. "application/vnd.github.v3.star+json", Args.ApiOptions);
  107. }
  108. [Fact]
  109. public async Task RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions()
  110. {
  111. var endpoint = new Uri("user/starred", UriKind.Relative);
  112. var connection = Substitute.For<IApiConnection>();
  113. var client = new StarredClient(connection);
  114. var options = new ApiOptions
  115. {
  116. PageCount = 1,
  117. StartPage = 1,
  118. PageSize = 1
  119. };
  120. var request = new StarredRequest { SortDirection = SortDirection.Ascending };
  121. await client.GetAllForCurrentWithTimestamps(request, options);
  122. connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"),
  123. "application/vnd.github.v3.star+json", options);
  124. }
  125. [Fact]
  126. public async Task EnsuresNonNullArguments()
  127. {
  128. var client = new StarredClient(Substitute.For<IApiConnection>());
  129. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null));
  130. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((StarredRequest)null));
  131. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps((ApiOptions)null));
  132. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps((StarredRequest)null));
  133. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent(null, new ApiOptions()));
  134. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent(new StarredRequest(), null));
  135. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps(null, new ApiOptions()));
  136. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps(new StarredRequest(), null));
  137. }
  138. }
  139. public class TheGetAllForUserMethod
  140. {
  141. [Fact]
  142. public async Task RequestsCorrectUrl()
  143. {
  144. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  145. var connection = Substitute.For<IApiConnection>();
  146. var client = new StarredClient(connection);
  147. await client.GetAllForUser("banana");
  148. connection.Received().GetAll<Repository>(endpoint, Args.ApiOptions);
  149. }
  150. [Fact]
  151. public async Task RequestsCorrectUrlWithApiOptions()
  152. {
  153. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  154. var connection = Substitute.For<IApiConnection>();
  155. var client = new StarredClient(connection);
  156. var options = new ApiOptions
  157. {
  158. PageCount = 1,
  159. StartPage = 1,
  160. PageSize = 1
  161. };
  162. await client.GetAllForUser("banana", options);
  163. connection.Received().GetAll<Repository>(endpoint, options);
  164. }
  165. [Fact]
  166. public async Task RequestsCorrectUrlParametrized()
  167. {
  168. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  169. var connection = Substitute.For<IApiConnection>();
  170. var client = new StarredClient(connection);
  171. var starredRequest = new StarredRequest { SortDirection = SortDirection.Ascending };
  172. await client.GetAllForUser("banana", starredRequest);
  173. connection.Received().GetAll<Repository>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), Args.ApiOptions);
  174. }
  175. [Fact]
  176. public async Task RequestsCorrectUrlParametrizedWithApiOptions()
  177. {
  178. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  179. var connection = Substitute.For<IApiConnection>();
  180. var client = new StarredClient(connection);
  181. var options = new ApiOptions
  182. {
  183. PageCount = 1,
  184. StartPage = 1,
  185. PageSize = 1
  186. };
  187. var starredRequest = new StarredRequest { SortDirection = SortDirection.Ascending };
  188. await client.GetAllForUser("banana", starredRequest, options);
  189. connection.Received().GetAll<Repository>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), options);
  190. }
  191. [Fact]
  192. public async Task RequestsCorrectUrlWithTimestamps()
  193. {
  194. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  195. var connection = Substitute.For<IApiConnection>();
  196. var client = new StarredClient(connection);
  197. await client.GetAllForUserWithTimestamps("banana");
  198. connection.Received().GetAll<RepositoryStar>(endpoint, null,
  199. "application/vnd.github.v3.star+json", Args.ApiOptions);
  200. }
  201. [Fact]
  202. public async Task RequestsCorrectUrlWithTimestampsWithApiOptions()
  203. {
  204. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  205. var connection = Substitute.For<IApiConnection>();
  206. var client = new StarredClient(connection);
  207. var options = new ApiOptions
  208. {
  209. PageCount = 1,
  210. StartPage = 1,
  211. PageSize = 1
  212. };
  213. await client.GetAllForUserWithTimestamps("banana", options);
  214. connection.Received().GetAll<RepositoryStar>(endpoint, null, "application/vnd.github.v3.star+json", options);
  215. }
  216. [Fact]
  217. public async Task RequestsCorrectUrlWithTimestampsParametrized()
  218. {
  219. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  220. var connection = Substitute.For<IApiConnection>();
  221. var client = new StarredClient(connection);
  222. var starredRequest = new StarredRequest { SortDirection = SortDirection.Ascending };
  223. await client.GetAllForUserWithTimestamps("banana", starredRequest);
  224. connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"),
  225. "application/vnd.github.v3.star+json", Args.ApiOptions);
  226. }
  227. [Fact]
  228. public async Task RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions()
  229. {
  230. var endpoint = new Uri("users/banana/starred", UriKind.Relative);
  231. var connection = Substitute.For<IApiConnection>();
  232. var client = new StarredClient(connection);
  233. var options = new ApiOptions
  234. {
  235. PageCount = 1,
  236. StartPage = 1,
  237. PageSize = 1
  238. };
  239. var starredRequest = new StarredRequest { SortDirection = SortDirection.Ascending };
  240. await client.GetAllForUserWithTimestamps("banana", starredRequest, options);
  241. connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"),
  242. "application/vnd.github.v3.star+json", options);
  243. }
  244. [Fact]
  245. public async Task EnsuresNonNullArguments()
  246. {
  247. var client = new StarredClient(Substitute.For<IApiConnection>());
  248. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null));
  249. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null, ApiOptions.None));
  250. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser("banana", (ApiOptions)null));
  251. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null, new StarredRequest()));
  252. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser("banana", (StarredRequest)null));
  253. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null, new StarredRequest(), ApiOptions.None));
  254. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser("banana", null, ApiOptions.None));
  255. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser("banana", new StarredRequest(), null));
  256. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null));
  257. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, ApiOptions.None));
  258. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", (ApiOptions)null));
  259. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, new StarredRequest()));
  260. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", (StarredRequest)null));
  261. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, new StarredRequest(), ApiOptions.None));
  262. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", null, ApiOptions.None));
  263. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", new StarredRequest(), null));
  264. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser(""));
  265. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", ApiOptions.None));
  266. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", new StarredRequest(), ApiOptions.None));
  267. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUserWithTimestamps(""));
  268. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUserWithTimestamps("", ApiOptions.None));
  269. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUserWithTimestamps("", new StarredRequest(), ApiOptions.None));
  270. }
  271. }
  272. public class TheGetAllStargazersForRepoMethod
  273. {
  274. [Fact]
  275. public async Task RequestsCorrectUrl()
  276. {
  277. var endpoint = new Uri("repos/fight/club/stargazers", UriKind.Relative);
  278. var connection = Substitute.For<IApiConnection>();
  279. var client = new StarredClient(connection);
  280. await client.GetAllStargazers("fight", "club");
  281. connection.Received().GetAll<User>(endpoint, Args.ApiOptions);
  282. }
  283. [Fact]
  284. public async Task RequestsCorrectUrlWithRepositoryId()
  285. {
  286. var endpoint = new Uri("repositories/1/stargazers", UriKind.Relative);
  287. var connection = Substitute.For<IApiConnection>();
  288. var client = new StarredClient(connection);
  289. await client.GetAllStargazers(1);
  290. connection.Received().GetAll<User>(endpoint, Args.ApiOptions);
  291. }
  292. [Fact]
  293. public async Task RequestsCorrectUrlWithApiOptions()
  294. {
  295. var endpoint = new Uri("repos/fight/club/stargazers", UriKind.Relative);
  296. var connection = Substitute.For<IApiConnection>();
  297. var client = new StarredClient(connection);
  298. var options = new ApiOptions
  299. {
  300. PageCount = 1,
  301. StartPage = 1,
  302. PageSize = 1
  303. };
  304. await client.GetAllStargazers("fight", "club", options);
  305. connection.Received().GetAll<User>(endpoint, options);
  306. }
  307. [Fact]
  308. public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
  309. {
  310. var endpoint = new Uri("repositories/1/stargazers", UriKind.Relative);
  311. var connection = Substitute.For<IApiConnection>();
  312. var client = new StarredClient(connection);
  313. var options = new ApiOptions
  314. {
  315. PageCount = 1,
  316. StartPage = 1,
  317. PageSize = 1
  318. };
  319. await client.GetAllStargazers(1, options);
  320. connection.Received().GetAll<User>(endpoint, options);
  321. }
  322. [Fact]
  323. public async Task RequestsCorrectUrlWithTimestamps()
  324. {
  325. var endpoint = new Uri("repos/fake/repo/stargazers", UriKind.Relative);
  326. var connection = Substitute.For<IApiConnection>();
  327. var client = new StarredClient(connection);
  328. await client.GetAllStargazersWithTimestamps("fake", "repo");
  329. connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", Args.ApiOptions);
  330. }
  331. [Fact]
  332. public async Task RequestsCorrectUrlWithTimestampsWithRepositoryId()
  333. {
  334. var endpoint = new Uri("repositories/1/stargazers", UriKind.Relative);
  335. var connection = Substitute.For<IApiConnection>();
  336. var client = new StarredClient(connection);
  337. await client.GetAllStargazersWithTimestamps(1);
  338. connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", Args.ApiOptions);
  339. }
  340. [Fact]
  341. public async Task RequestsCorrectUrlWithTimestampsWithApiOptions()
  342. {
  343. var endpoint = new Uri("repos/fake/repo/stargazers", UriKind.Relative);
  344. var connection = Substitute.For<IApiConnection>();
  345. var client = new StarredClient(connection);
  346. var options = new ApiOptions
  347. {
  348. PageCount = 1,
  349. StartPage = 1,
  350. PageSize = 1
  351. };
  352. await client.GetAllStargazersWithTimestamps("fake", "repo", options);
  353. connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", options);
  354. }
  355. [Fact]
  356. public async Task RequestsCorrectUrlWithTimestampsWithApiOptionsWithRepositoryId()
  357. {
  358. var endpoint = new Uri("repositories/1/stargazers", UriKind.Relative);
  359. var connection = Substitute.For<IApiConnection>();
  360. var client = new StarredClient(connection);
  361. var options = new ApiOptions
  362. {
  363. PageCount = 1,
  364. StartPage = 1,
  365. PageSize = 1
  366. };
  367. await client.GetAllStargazersWithTimestamps(1, options);
  368. connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", options);
  369. }
  370. [Fact]
  371. public async Task EnsuresNonNullArguments()
  372. {
  373. var client = new StarredClient(Substitute.For<IApiConnection>());
  374. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazers(null, "club"));
  375. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazers("fight", null));
  376. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazers(null, "club", ApiOptions.None));
  377. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazers("fight", null, ApiOptions.None));
  378. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazers("fight", "club", null));
  379. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazersWithTimestamps(null, "club"));
  380. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazersWithTimestamps("fight", null));
  381. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazersWithTimestamps(null, "club", ApiOptions.None));
  382. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazersWithTimestamps("fight", null, ApiOptions.None));
  383. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazersWithTimestamps("fight", "club", null));
  384. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazers(1, null));
  385. await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllStargazersWithTimestamps(1, null));
  386. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazers("", "club"));
  387. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazers("fight", ""));
  388. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazers("", "club", ApiOptions.None));
  389. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazers("fight", "", ApiOptions.None));
  390. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazersWithTimestamps("", "club"));
  391. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazersWithTimestamps("fight", ""));
  392. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazersWithTimestamps("", "club", ApiOptions.None));
  393. await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllStargazersWithTimestamps("fight", "", ApiOptions.None));
  394. }
  395. }
  396. public class TheCheckStarredMethod
  397. {
  398. [Theory]
  399. [InlineData(HttpStatusCode.NoContent, true)]
  400. [InlineData(HttpStatusCode.NotFound, false)]
  401. public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
  402. {
  403. var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
  404. new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
  405. var connection = Substitute.For<IConnection>();
  406. connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"), null, null)
  407. .Returns(response);
  408. var apiConnection = Substitute.For<IApiConnection>();
  409. apiConnection.Connection.Returns(connection);
  410. var client = new StarredClient(apiConnection);
  411. var result = await client.CheckStarred("yes", "no");
  412. Assert.Equal(expected, result);
  413. }
  414. }
  415. public class TheStarRepoMethod
  416. {
  417. [Theory]
  418. [InlineData(HttpStatusCode.NoContent, true)]
  419. [InlineData(HttpStatusCode.NotFound, false)]
  420. [InlineData(HttpStatusCode.OK, false)]
  421. public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
  422. {
  423. var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
  424. new ApiResponse<object>(new Response(status, null, new Dictionary<string, string>(), "application/json")));
  425. var connection = Substitute.For<IConnection>();
  426. connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"),
  427. Args.Object, Args.String).Returns(response);
  428. var apiConnection = Substitute.For<IApiConnection>();
  429. apiConnection.Connection.Returns(connection);
  430. var client = new StarredClient(apiConnection);
  431. var result = await client.StarRepo("yes", "no");
  432. Assert.Equal(expected, result);
  433. }
  434. }
  435. public class TheRemoveStarFromRepoMethod
  436. {
  437. [Theory]
  438. [InlineData(HttpStatusCode.NoContent, true)]
  439. [InlineData(HttpStatusCode.NotFound, false)]
  440. [InlineData(HttpStatusCode.OK, false)]
  441. public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
  442. {
  443. var response = Task.Factory.StartNew(() => status);
  444. var connection = Substitute.For<IConnection>();
  445. connection.Delete(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"))
  446. .Returns(response);
  447. var apiConnection = Substitute.For<IApiConnection>();
  448. apiConnection.Connection.Returns(connection);
  449. var client = new StarredClient(apiConnection);
  450. var result = await client.RemoveStarFromRepo("yes", "no");
  451. Assert.Equal(expected, result);
  452. }
  453. }
  454. }
  455. }