PageRenderTime 27ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs

https://gitlab.com/WoomyNightClub/GitHub-API-.NET
C# | 783 lines | 623 code | 160 blank | 0 comment | 0 complexity | f40cbd4e361b47a14859d5599c333e31 MD5 | raw file
  1. using System.Linq;
  2. using System.Reactive.Linq;
  3. using System.Threading.Tasks;
  4. using Octokit.Reactive;
  5. using Xunit;
  6. namespace Octokit.Tests.Integration.Reactive
  7. {
  8. public class ObservableEventsClientTests
  9. {
  10. public class TheGetAllMethod
  11. {
  12. readonly ObservableEventsClient _eventsClient;
  13. public TheGetAllMethod()
  14. {
  15. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  16. }
  17. [IntegrationTest]
  18. public async Task ReturnsEvents()
  19. {
  20. var events = await _eventsClient.GetAll().ToList();
  21. Assert.NotEmpty(events);
  22. }
  23. [IntegrationTest]
  24. public async Task ReturnsCorrectCountOfEventsWithoutStart()
  25. {
  26. var options = new ApiOptions
  27. {
  28. PageSize = 5,
  29. PageCount = 1
  30. };
  31. var events = await _eventsClient.GetAll(options).ToList();
  32. Assert.Equal(5, events.Count);
  33. }
  34. [IntegrationTest]
  35. public async Task ReturnsCorrectCountOfEventsWithStart()
  36. {
  37. var options = new ApiOptions
  38. {
  39. PageSize = 5,
  40. PageCount = 1,
  41. StartPage = 2
  42. };
  43. var events = await _eventsClient.GetAll(options).ToList();
  44. Assert.Equal(5, events.Count);
  45. }
  46. [IntegrationTest]
  47. public async Task ReturnsDistinctEventsBasedOnStartPage()
  48. {
  49. var startOptions = new ApiOptions
  50. {
  51. PageSize = 5,
  52. PageCount = 1
  53. };
  54. var firstEventsPage = await _eventsClient.GetAll(startOptions).ToList();
  55. var skipStartOptions = new ApiOptions
  56. {
  57. PageSize = 5,
  58. PageCount = 1,
  59. StartPage = 2
  60. };
  61. var secondEventsPage = await _eventsClient.GetAll(skipStartOptions).ToList();
  62. Assert.NotEqual(firstEventsPage[0].Id, secondEventsPage[0].Id);
  63. Assert.NotEqual(firstEventsPage[1].Id, secondEventsPage[1].Id);
  64. Assert.NotEqual(firstEventsPage[2].Id, secondEventsPage[2].Id);
  65. Assert.NotEqual(firstEventsPage[3].Id, secondEventsPage[3].Id);
  66. Assert.NotEqual(firstEventsPage[4].Id, secondEventsPage[4].Id);
  67. }
  68. }
  69. public class TheGetAllForRepositoryMethod
  70. {
  71. readonly ObservableEventsClient _eventsClient;
  72. const string owner = "octokit";
  73. const string name = "octokit.net";
  74. public TheGetAllForRepositoryMethod()
  75. {
  76. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  77. }
  78. [IntegrationTest]
  79. public async Task ReturnsRepositoryEvents()
  80. {
  81. var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name).ToList();
  82. Assert.NotEmpty(repositoryEvents);
  83. }
  84. [IntegrationTest]
  85. public async Task ReturnsCorrectCountOfRepositoryEventsWithoutStart()
  86. {
  87. var options = new ApiOptions
  88. {
  89. PageSize = 5,
  90. PageCount = 1
  91. };
  92. var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name, options).ToList();
  93. Assert.Equal(5, repositoryEvents.Count);
  94. }
  95. [IntegrationTest]
  96. public async Task ReturnsCorrectCountOfRepositoryEventsWithStart()
  97. {
  98. var options = new ApiOptions
  99. {
  100. PageSize = 5,
  101. PageCount = 1,
  102. StartPage = 2
  103. };
  104. var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name, options).ToList();
  105. Assert.Equal(5, repositoryEvents.Count);
  106. }
  107. [IntegrationTest]
  108. public async Task ReturnsDistinctRepositoryEventsBasedOnStartPage()
  109. {
  110. var startOptions = new ApiOptions
  111. {
  112. PageSize = 5,
  113. PageCount = 1
  114. };
  115. var firstRepositoryEventsPage = await _eventsClient.GetAllForRepository(owner, name, startOptions).ToList();
  116. var skipStartOptions = new ApiOptions
  117. {
  118. PageSize = 5,
  119. PageCount = 1,
  120. StartPage = 2
  121. };
  122. var secondRepositoryEventsPage = await _eventsClient.GetAllForRepository(owner, name, skipStartOptions).ToList();
  123. Assert.NotEqual(firstRepositoryEventsPage[0].Id, secondRepositoryEventsPage[0].Id);
  124. Assert.NotEqual(firstRepositoryEventsPage[1].Id, secondRepositoryEventsPage[1].Id);
  125. Assert.NotEqual(firstRepositoryEventsPage[2].Id, secondRepositoryEventsPage[2].Id);
  126. Assert.NotEqual(firstRepositoryEventsPage[3].Id, secondRepositoryEventsPage[3].Id);
  127. Assert.NotEqual(firstRepositoryEventsPage[4].Id, secondRepositoryEventsPage[4].Id);
  128. }
  129. }
  130. public class TheGetAllIssuesForRepositoryMethod
  131. {
  132. readonly ObservableEventsClient _eventsClient;
  133. const string owner = "octokit";
  134. const string name = "octokit.net";
  135. public TheGetAllIssuesForRepositoryMethod()
  136. {
  137. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  138. }
  139. [IntegrationTest]
  140. public async Task ReturnsRepositoryEvents()
  141. {
  142. var options = new ApiOptions
  143. {
  144. PageCount = 1,
  145. StartPage = 1,
  146. PageSize = 5
  147. };
  148. var repositoryEvents = await _eventsClient.GetAllIssuesForRepository(owner, name, options).ToList();
  149. Assert.NotEmpty(repositoryEvents);
  150. }
  151. [IntegrationTest]
  152. public async Task ReturnsCorrectCountOfRepositoryEventsWithoutStart()
  153. {
  154. var options = new ApiOptions
  155. {
  156. PageSize = 5,
  157. PageCount = 1
  158. };
  159. var repositoryEvents = await _eventsClient.GetAllIssuesForRepository(owner, name, options).ToList();
  160. Assert.Equal(5, repositoryEvents.Count);
  161. }
  162. [IntegrationTest]
  163. public async Task ReturnsCorrectCountOfRepositoryEventsWithStart()
  164. {
  165. var options = new ApiOptions
  166. {
  167. PageSize = 5,
  168. PageCount = 1,
  169. StartPage = 2
  170. };
  171. var repositoryEvents = await _eventsClient.GetAllIssuesForRepository(owner, name, options).ToList();
  172. Assert.Equal(5, repositoryEvents.Count);
  173. }
  174. [IntegrationTest]
  175. public async Task ReturnsDistinctRepositoryEventsBasedOnStartPage()
  176. {
  177. var startOptions = new ApiOptions
  178. {
  179. PageSize = 5,
  180. PageCount = 1
  181. };
  182. var firstRepositoryEventsPage = await _eventsClient.GetAllIssuesForRepository(owner, name, startOptions).ToList();
  183. var skipStartOptions = new ApiOptions
  184. {
  185. PageSize = 5,
  186. PageCount = 1,
  187. StartPage = 2
  188. };
  189. var secondRepositoryEventsPage = await _eventsClient.GetAllIssuesForRepository(owner, name, skipStartOptions).ToList();
  190. Assert.NotEqual(firstRepositoryEventsPage[0].Id, secondRepositoryEventsPage[0].Id);
  191. Assert.NotEqual(firstRepositoryEventsPage[1].Id, secondRepositoryEventsPage[1].Id);
  192. Assert.NotEqual(firstRepositoryEventsPage[2].Id, secondRepositoryEventsPage[2].Id);
  193. Assert.NotEqual(firstRepositoryEventsPage[3].Id, secondRepositoryEventsPage[3].Id);
  194. Assert.NotEqual(firstRepositoryEventsPage[4].Id, secondRepositoryEventsPage[4].Id);
  195. }
  196. }
  197. public class TheGetAllForRepositoryNetworkMethod
  198. {
  199. readonly ObservableEventsClient _eventsClient;
  200. const string owner = "octokit";
  201. const string name = "octokit.net";
  202. public TheGetAllForRepositoryNetworkMethod()
  203. {
  204. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  205. }
  206. [IntegrationTest]
  207. public async Task ReturnsRepositoryNetworkEvents()
  208. {
  209. var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name).ToList();
  210. Assert.NotEmpty(repositoryNetworkEvents);
  211. }
  212. [IntegrationTest]
  213. public async Task ReturnsCorrectCountOfRepositoryNetworkEventsWithoutStart()
  214. {
  215. var options = new ApiOptions
  216. {
  217. PageSize = 5,
  218. PageCount = 1
  219. };
  220. var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name, options).ToList();
  221. Assert.Equal(5, repositoryNetworkEvents.Count);
  222. }
  223. [IntegrationTest]
  224. public async Task ReturnsCorrectCountOfRepositoryNetworkEventsWithStart()
  225. {
  226. var options = new ApiOptions
  227. {
  228. PageSize = 5,
  229. PageCount = 1,
  230. StartPage = 2
  231. };
  232. var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name, options).ToList();
  233. Assert.Equal(5, repositoryNetworkEvents.Count);
  234. }
  235. [IntegrationTest]
  236. public async Task ReturnsDistinctRepositoryNetworkEventsBasedOnStartPage()
  237. {
  238. var startOptions = new ApiOptions
  239. {
  240. PageSize = 5,
  241. PageCount = 1
  242. };
  243. var firstRepositoryNetworkEventsPage = await _eventsClient.GetAllForRepositoryNetwork(owner, name, startOptions).ToList();
  244. var skipStartOptions = new ApiOptions
  245. {
  246. PageSize = 5,
  247. PageCount = 1,
  248. StartPage = 2
  249. };
  250. var secondRepositoryNetworkEventsPage = await _eventsClient.GetAllForRepositoryNetwork(owner, name, skipStartOptions).ToList();
  251. Assert.NotEqual(firstRepositoryNetworkEventsPage[0].Id, secondRepositoryNetworkEventsPage[0].Id);
  252. Assert.NotEqual(firstRepositoryNetworkEventsPage[1].Id, secondRepositoryNetworkEventsPage[1].Id);
  253. Assert.NotEqual(firstRepositoryNetworkEventsPage[2].Id, secondRepositoryNetworkEventsPage[2].Id);
  254. Assert.NotEqual(firstRepositoryNetworkEventsPage[3].Id, secondRepositoryNetworkEventsPage[3].Id);
  255. Assert.NotEqual(firstRepositoryNetworkEventsPage[4].Id, secondRepositoryNetworkEventsPage[4].Id);
  256. }
  257. }
  258. public class TheGetAllForOrganizationMethod
  259. {
  260. readonly ObservableEventsClient _eventsClient;
  261. const string organization = "octokit";
  262. public TheGetAllForOrganizationMethod()
  263. {
  264. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  265. }
  266. [IntegrationTest]
  267. public async Task ReturnsOrganizationEvents()
  268. {
  269. var organizationEvents = await _eventsClient.GetAllForOrganization(organization).ToList();
  270. Assert.NotEmpty(organizationEvents);
  271. }
  272. [IntegrationTest]
  273. public async Task ReturnsCorrectCountOfOrganizationEventsWithoutStart()
  274. {
  275. var options = new ApiOptions
  276. {
  277. PageSize = 5,
  278. PageCount = 1
  279. };
  280. var organizationEvents = await _eventsClient.GetAllForOrganization(organization, options).ToList();
  281. Assert.Equal(5, organizationEvents.Count);
  282. }
  283. [IntegrationTest]
  284. public async Task ReturnsCorrectCountOfOrganizationEventsWithStart()
  285. {
  286. var options = new ApiOptions
  287. {
  288. PageSize = 5,
  289. PageCount = 1,
  290. StartPage = 2
  291. };
  292. var organizationEvents = await _eventsClient.GetAllForOrganization(organization, options).ToList();
  293. Assert.Equal(5, organizationEvents.Count);
  294. }
  295. [IntegrationTest]
  296. public async Task ReturnsDistinctOrganizationEventsBasedOnStartPage()
  297. {
  298. var startOptions = new ApiOptions
  299. {
  300. PageSize = 5,
  301. PageCount = 1
  302. };
  303. var firstOrganizationEventsPage = await _eventsClient.GetAllForOrganization(organization, startOptions).ToList();
  304. var skipStartOptions = new ApiOptions
  305. {
  306. PageSize = 5,
  307. PageCount = 1,
  308. StartPage = 2
  309. };
  310. var secondOrganizationEventsPage = await _eventsClient.GetAllForOrganization(organization, skipStartOptions).ToList();
  311. Assert.NotEqual(firstOrganizationEventsPage[0].Id, secondOrganizationEventsPage[0].Id);
  312. Assert.NotEqual(firstOrganizationEventsPage[1].Id, secondOrganizationEventsPage[1].Id);
  313. Assert.NotEqual(firstOrganizationEventsPage[2].Id, secondOrganizationEventsPage[2].Id);
  314. Assert.NotEqual(firstOrganizationEventsPage[3].Id, secondOrganizationEventsPage[3].Id);
  315. Assert.NotEqual(firstOrganizationEventsPage[4].Id, secondOrganizationEventsPage[4].Id);
  316. }
  317. }
  318. public class TheGetAllUserReceivedMethod
  319. {
  320. readonly ObservableEventsClient _eventsClient;
  321. const string user = "shiftkey";
  322. public TheGetAllUserReceivedMethod()
  323. {
  324. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  325. }
  326. [IntegrationTest]
  327. public async Task ReturnsUserReceivedEvents()
  328. {
  329. var userReceivedEvents = await _eventsClient.GetAllUserReceived(user).ToList();
  330. Assert.NotEmpty(userReceivedEvents);
  331. }
  332. [IntegrationTest]
  333. public async Task ReturnsCorrectCountOfUserReceivedEventsWithoutStart()
  334. {
  335. var options = new ApiOptions
  336. {
  337. PageSize = 5,
  338. PageCount = 1
  339. };
  340. var userReceivedEvents = await _eventsClient.GetAllUserReceived(user, options).ToList();
  341. Assert.Equal(5, userReceivedEvents.Count);
  342. }
  343. [IntegrationTest]
  344. public async Task ReturnsCorrectCountOfUserReceivedEventsWithStart()
  345. {
  346. var options = new ApiOptions
  347. {
  348. PageSize = 5,
  349. PageCount = 1,
  350. StartPage = 2
  351. };
  352. var userReceivedEvents = await _eventsClient.GetAllUserReceived(user, options).ToList();
  353. Assert.Equal(5, userReceivedEvents.Count);
  354. }
  355. [IntegrationTest]
  356. public async Task ReturnsDistinctUserReceivedEventsBasedOnStartPage()
  357. {
  358. var startOptions = new ApiOptions
  359. {
  360. PageSize = 5,
  361. PageCount = 1
  362. };
  363. var firstUserReceivedEventsPage = await _eventsClient.GetAllUserReceived(user, startOptions).ToList();
  364. var skipStartOptions = new ApiOptions
  365. {
  366. PageSize = 5,
  367. PageCount = 1,
  368. StartPage = 2
  369. };
  370. var secondUserReceivedEventsPage = await _eventsClient.GetAllUserReceived(user, skipStartOptions).ToList();
  371. Assert.NotEqual(firstUserReceivedEventsPage[0].Id, secondUserReceivedEventsPage[0].Id);
  372. Assert.NotEqual(firstUserReceivedEventsPage[1].Id, secondUserReceivedEventsPage[1].Id);
  373. Assert.NotEqual(firstUserReceivedEventsPage[2].Id, secondUserReceivedEventsPage[2].Id);
  374. Assert.NotEqual(firstUserReceivedEventsPage[3].Id, secondUserReceivedEventsPage[3].Id);
  375. Assert.NotEqual(firstUserReceivedEventsPage[4].Id, secondUserReceivedEventsPage[4].Id);
  376. }
  377. }
  378. public class TheGetAllUserReceivedPublicMethod
  379. {
  380. readonly ObservableEventsClient _eventsClient;
  381. const string user = "shiftkey";
  382. public TheGetAllUserReceivedPublicMethod()
  383. {
  384. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  385. }
  386. [IntegrationTest]
  387. public async Task ReturnsUserReceivedPublicEvents()
  388. {
  389. var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user).ToList();
  390. Assert.NotEmpty(userReceivedPublicEvents);
  391. }
  392. [IntegrationTest]
  393. public async Task ReturnsCorrectCountOfUserReceivedPublicEventsWithoutStart()
  394. {
  395. var options = new ApiOptions
  396. {
  397. PageSize = 5,
  398. PageCount = 1
  399. };
  400. var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user, options).ToList();
  401. Assert.Equal(5, userReceivedPublicEvents.Count);
  402. }
  403. [IntegrationTest]
  404. public async Task ReturnsCorrectCountOfUserReceivedPublicEventsWithStart()
  405. {
  406. var options = new ApiOptions
  407. {
  408. PageSize = 5,
  409. PageCount = 1,
  410. StartPage = 2
  411. };
  412. var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user, options).ToList();
  413. Assert.Equal(5, userReceivedPublicEvents.Count);
  414. }
  415. [IntegrationTest]
  416. public async Task ReturnsDistinctUserReceivedPublicEventsBasedOnStartPage()
  417. {
  418. var startOptions = new ApiOptions
  419. {
  420. PageSize = 5,
  421. PageCount = 1
  422. };
  423. var firstUserReceivedPublicEventsPage = await _eventsClient.GetAllUserReceivedPublic(user, startOptions).ToList();
  424. var skipStartOptions = new ApiOptions
  425. {
  426. PageSize = 5,
  427. PageCount = 1,
  428. StartPage = 2
  429. };
  430. var secondUserReceivedPublicEventsPage = await _eventsClient.GetAllUserReceivedPublic(user, skipStartOptions).ToList();
  431. Assert.NotEqual(firstUserReceivedPublicEventsPage[0].Id, secondUserReceivedPublicEventsPage[0].Id);
  432. Assert.NotEqual(firstUserReceivedPublicEventsPage[1].Id, secondUserReceivedPublicEventsPage[1].Id);
  433. Assert.NotEqual(firstUserReceivedPublicEventsPage[2].Id, secondUserReceivedPublicEventsPage[2].Id);
  434. Assert.NotEqual(firstUserReceivedPublicEventsPage[3].Id, secondUserReceivedPublicEventsPage[3].Id);
  435. Assert.NotEqual(firstUserReceivedPublicEventsPage[4].Id, secondUserReceivedPublicEventsPage[4].Id);
  436. }
  437. }
  438. public class TheGetAllUserPerformedMethod
  439. {
  440. readonly ObservableEventsClient _eventsClient;
  441. const string user = "shiftkey";
  442. public TheGetAllUserPerformedMethod()
  443. {
  444. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  445. }
  446. [IntegrationTest]
  447. public async Task ReturnsUserPerformedEvents()
  448. {
  449. var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user).ToList();
  450. Assert.NotEmpty(userPerformedEvents);
  451. }
  452. [IntegrationTest]
  453. public async Task ReturnsCorrectCountOfUserPerformedEventsWithoutStart()
  454. {
  455. var options = new ApiOptions
  456. {
  457. PageSize = 5,
  458. PageCount = 1
  459. };
  460. var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user, options).ToList();
  461. Assert.Equal(5, userPerformedEvents.Count);
  462. }
  463. [IntegrationTest]
  464. public async Task ReturnsCorrectCountOfUserPerformedEventsWithStart()
  465. {
  466. var options = new ApiOptions
  467. {
  468. PageSize = 5,
  469. PageCount = 1,
  470. StartPage = 2
  471. };
  472. var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user, options).ToList();
  473. Assert.Equal(5, userPerformedEvents.Count);
  474. }
  475. [IntegrationTest]
  476. public async Task ReturnsDistinctUserPerformedEventsBasedOnStartPage()
  477. {
  478. var startOptions = new ApiOptions
  479. {
  480. PageSize = 5,
  481. PageCount = 1
  482. };
  483. var firstUserPerformedEventsPage = await _eventsClient.GetAllUserPerformed(user, startOptions).ToList();
  484. var skipStartOptions = new ApiOptions
  485. {
  486. PageSize = 5,
  487. PageCount = 1,
  488. StartPage = 2
  489. };
  490. var secondUserPerformedEventsPage = await _eventsClient.GetAllUserPerformed(user, skipStartOptions).ToList();
  491. Assert.NotEqual(firstUserPerformedEventsPage[0].Id, secondUserPerformedEventsPage[0].Id);
  492. Assert.NotEqual(firstUserPerformedEventsPage[1].Id, secondUserPerformedEventsPage[1].Id);
  493. Assert.NotEqual(firstUserPerformedEventsPage[2].Id, secondUserPerformedEventsPage[2].Id);
  494. Assert.NotEqual(firstUserPerformedEventsPage[3].Id, secondUserPerformedEventsPage[3].Id);
  495. Assert.NotEqual(firstUserPerformedEventsPage[4].Id, secondUserPerformedEventsPage[4].Id);
  496. }
  497. }
  498. public class TheGetAllUserPerformedPublicMethod
  499. {
  500. readonly ObservableEventsClient _eventsClient;
  501. const string user = "shiftkey";
  502. public TheGetAllUserPerformedPublicMethod()
  503. {
  504. _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient());
  505. }
  506. [IntegrationTest]
  507. public async Task ReturnsUserPerformedPublicEvents()
  508. {
  509. var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user).ToList();
  510. Assert.NotEmpty(userPerformedPublicEvents);
  511. }
  512. [IntegrationTest]
  513. public async Task ReturnsCorrectCountOfUserPerformedPublicEventsWithoutStart()
  514. {
  515. var options = new ApiOptions
  516. {
  517. PageSize = 5,
  518. PageCount = 1
  519. };
  520. var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user, options).ToList();
  521. Assert.Equal(5, userPerformedPublicEvents.Count);
  522. }
  523. [IntegrationTest]
  524. public async Task ReturnsCorrectCountOfUserPerformedPublicEventsWithStart()
  525. {
  526. var options = new ApiOptions
  527. {
  528. PageSize = 5,
  529. PageCount = 1,
  530. StartPage = 2
  531. };
  532. var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user, options).ToList();
  533. Assert.Equal(5, userPerformedPublicEvents.Count);
  534. }
  535. [IntegrationTest]
  536. public async Task ReturnsDistinctUserPerformedPublicEventsBasedOnStartPage()
  537. {
  538. var startOptions = new ApiOptions
  539. {
  540. PageSize = 5,
  541. PageCount = 1
  542. };
  543. var firstUserPerformedPublicEventsPage = await _eventsClient.GetAllUserPerformedPublic(user, startOptions).ToList();
  544. var skipStartOptions = new ApiOptions
  545. {
  546. PageSize = 5,
  547. PageCount = 1,
  548. StartPage = 2
  549. };
  550. var secondUserPerformedPublicEventsPage = await _eventsClient.GetAllUserPerformedPublic(user, skipStartOptions).ToList();
  551. Assert.NotEqual(firstUserPerformedPublicEventsPage[0].Id, secondUserPerformedPublicEventsPage[0].Id);
  552. Assert.NotEqual(firstUserPerformedPublicEventsPage[1].Id, secondUserPerformedPublicEventsPage[1].Id);
  553. Assert.NotEqual(firstUserPerformedPublicEventsPage[2].Id, secondUserPerformedPublicEventsPage[2].Id);
  554. Assert.NotEqual(firstUserPerformedPublicEventsPage[3].Id, secondUserPerformedPublicEventsPage[3].Id);
  555. Assert.NotEqual(firstUserPerformedPublicEventsPage[4].Id, secondUserPerformedPublicEventsPage[4].Id);
  556. }
  557. }
  558. public class TheGetAllForAnOrganizationMethod
  559. {
  560. readonly ObservableEventsClient _eventsClient;
  561. readonly string _organization;
  562. readonly string _user;
  563. public TheGetAllForAnOrganizationMethod()
  564. {
  565. var github = Helper.GetAuthenticatedClient();
  566. _eventsClient = new ObservableEventsClient(github);
  567. _user = Helper.UserName;
  568. _organization = Helper.Organization;
  569. }
  570. [IntegrationTest]
  571. public async Task ReturnsUserOrganizationEvents()
  572. {
  573. var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user,_organization).ToList();
  574. Assert.NotEmpty(userOrganizationEvents);
  575. }
  576. [IntegrationTest]
  577. public async Task ReturnsCorrectCountOfUserOrganizationEventsWithoutStart()
  578. {
  579. var options = new ApiOptions
  580. {
  581. PageSize = 5,
  582. PageCount = 1
  583. };
  584. var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user, _organization, options).ToList();
  585. Assert.Equal(5, userOrganizationEvents.Count);
  586. }
  587. [IntegrationTest]
  588. public async Task ReturnsCorrectCountOfUserOrganizationEventsWithStart()
  589. {
  590. var options = new ApiOptions
  591. {
  592. PageSize = 5,
  593. PageCount = 1,
  594. StartPage = 2
  595. };
  596. var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user, _organization, options).ToList();
  597. Assert.Equal(5, userOrganizationEvents.Count);
  598. }
  599. [IntegrationTest]
  600. public async Task ReturnsDistinctUserOrganizationEventsBasedOnStartPage()
  601. {
  602. var startOptions = new ApiOptions
  603. {
  604. PageSize = 5,
  605. PageCount = 1
  606. };
  607. var firstUserOrganizationEventsPage = await _eventsClient.GetAllForAnOrganization(_user, _organization, startOptions).ToList();
  608. var skipStartOptions = new ApiOptions
  609. {
  610. PageSize = 5,
  611. PageCount = 1,
  612. StartPage = 2
  613. };
  614. var secondUserOrganizationEventsPage = await _eventsClient.GetAllForAnOrganization(_user, _organization, skipStartOptions).ToList();
  615. Assert.NotEqual(firstUserOrganizationEventsPage[0].Id, secondUserOrganizationEventsPage[0].Id);
  616. Assert.NotEqual(firstUserOrganizationEventsPage[1].Id, secondUserOrganizationEventsPage[1].Id);
  617. Assert.NotEqual(firstUserOrganizationEventsPage[2].Id, secondUserOrganizationEventsPage[2].Id);
  618. Assert.NotEqual(firstUserOrganizationEventsPage[3].Id, secondUserOrganizationEventsPage[3].Id);
  619. Assert.NotEqual(firstUserOrganizationEventsPage[4].Id, secondUserOrganizationEventsPage[4].Id);
  620. }
  621. }
  622. }
  623. }