TestSourceControlProvider.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using System.Collections.Generic;
  3. using JetBrains.Annotations;
  4. using NUnit.Framework;
  5. using Unity.Cloud.Collaborate.Models.Api;
  6. using Unity.Cloud.Collaborate.Models.Enums;
  7. using Unity.Cloud.Collaborate.Models.Structures;
  8. namespace Unity.Cloud.Collaborate.Tests.Models
  9. {
  10. internal class TestSourceControlProvider : ISourceControlProvider
  11. {
  12. public int RequestedHistoryRevisionCount;
  13. [CanBeNull]
  14. public string RequestedHistoryRevisionId;
  15. public int RequestedHistoryListCount;
  16. public int? RequestedHistoryListOffset;
  17. public int? RequestedHistoryListSize;
  18. public int RequestedHistoryCountCount;
  19. public int RequestedUpdateToCount;
  20. [CanBeNull]
  21. public string RequestedUpdateToRevisionId;
  22. public int RequestedRestoreToCount;
  23. [CanBeNull]
  24. public string RequestedRestoreToRevisionId;
  25. public int RequestedGoBackToCount;
  26. [CanBeNull]
  27. public string RequestedGoBackToRevisionId;
  28. public int RequestedRevertCount;
  29. [CanBeNull]
  30. public string RequestedRevertRevisionId;
  31. public int? RequestedRevertFileCount;
  32. public int RequestedChangeListCount;
  33. [CanBeNull]
  34. public Action<IReadOnlyList<IChangeEntry>> RequestedChangeListCallback;
  35. public int RequestedDiscardCount;
  36. [CanBeNull]
  37. public IChangeEntry RequestedDiscardEntry;
  38. public int RequestedBulkDiscardCount;
  39. [CanBeNull]
  40. public IReadOnlyList<IChangeEntry> RequestedBulkDiscardPaths;
  41. public int RequestedDiffChangesCount;
  42. [CanBeNull]
  43. public string RequestedDiffChangesPath;
  44. public int RequestedPublishCount;
  45. [CanBeNull]
  46. public string RequestedPublishMessage;
  47. [CanBeNull]
  48. public IReadOnlyList<IChangeEntry> RequestedPublishList;
  49. public bool RemoteRevisionAvailability = false;
  50. public bool ConflictedState = false;
  51. public event Action UpdatedChangeList = delegate { };
  52. public event Action UpdatedHistoryEntries = delegate { };
  53. public event Action<bool> UpdatedConflictState = delegate { };
  54. public event Action<bool> UpdatedRemoteRevisionsAvailability = delegate { };
  55. public event Action<ProjectStatus> UpdatedProjectStatus = delegate { };
  56. public event Action<bool> UpdatedOperationStatus = delegate { };
  57. public event Action<IProgressInfo> UpdatedOperationProgress = delegate { };
  58. public event Action<IErrorInfo> ErrorOccurred = delegate { };
  59. public event Action ErrorCleared = delegate { };
  60. public event Action<IReadOnlyList<string>> UpdatedSelectedChangeList = delegate { };
  61. public bool GetRemoteRevisionAvailability()
  62. {
  63. return RemoteRevisionAvailability;
  64. }
  65. public bool GetConflictedState()
  66. {
  67. return ConflictedState;
  68. }
  69. public IProgressInfo GetProgressState()
  70. {
  71. throw new NotImplementedException();
  72. }
  73. public IErrorInfo GetErrorState()
  74. {
  75. throw new NotImplementedException();
  76. }
  77. public ProjectStatus GetProjectStatus()
  78. {
  79. throw new NotImplementedException();
  80. }
  81. public void RequestChangeList(Action<IReadOnlyList<IChangeEntry>> callback)
  82. {
  83. RequestedChangeListCount++;
  84. RequestedChangeListCallback = callback;
  85. }
  86. public void RequestPublish(string message, IReadOnlyList<IChangeEntry> changes = null)
  87. {
  88. RequestedPublishCount++;
  89. RequestedPublishMessage = message;
  90. RequestedPublishList = changes;
  91. }
  92. public void TriggerUpdatedHistoryEntries()
  93. {
  94. Assert.NotNull(UpdatedHistoryEntries, "There should be a listener registered.");
  95. UpdatedHistoryEntries();
  96. }
  97. public void TriggerUpdatedChangeEntries()
  98. {
  99. Assert.NotNull(UpdatedHistoryEntries, "There should be a listener registered.");
  100. UpdatedChangeList();
  101. }
  102. public void RequestHistoryEntry(string revisionId, Action<IHistoryEntry> callback)
  103. {
  104. RequestedHistoryRevisionCount++;
  105. RequestedHistoryRevisionId = revisionId;
  106. callback(null);
  107. }
  108. public void RequestHistoryPage(int offset, int pageSize, Action<IReadOnlyList<IHistoryEntry>> callback)
  109. {
  110. RequestedHistoryListCount++;
  111. RequestedHistoryListOffset = offset;
  112. RequestedHistoryListSize = pageSize;
  113. callback(null);
  114. }
  115. public void RequestHistoryCount(Action<int?> callback)
  116. {
  117. RequestedHistoryCountCount++;
  118. callback(null);
  119. }
  120. public void RequestDiscard(IChangeEntry entry)
  121. {
  122. RequestedDiscardCount++;
  123. RequestedDiscardEntry = entry;
  124. }
  125. public void RequestBulkDiscard(IReadOnlyList<IChangeEntry> entries)
  126. {
  127. RequestedBulkDiscardCount++;
  128. RequestedBulkDiscardPaths = entries;
  129. }
  130. public void RequestDiffChanges(string path)
  131. {
  132. RequestedDiffChangesCount++;
  133. RequestedDiffChangesPath = path;
  134. }
  135. public bool SupportsRevert { get; } = false;
  136. public void RequestRevert(string revisionId, IReadOnlyList<string> files)
  137. {
  138. RequestedRevertCount++;
  139. RequestedRevertRevisionId = revisionId;
  140. RequestedRevertFileCount = files.Count;
  141. }
  142. public void RequestUpdateTo(string revisionId)
  143. {
  144. RequestedUpdateToCount++;
  145. RequestedUpdateToRevisionId = revisionId;
  146. }
  147. public void RequestRestoreTo(string revisionId)
  148. {
  149. RequestedRestoreToCount++;
  150. RequestedRestoreToRevisionId = revisionId;
  151. }
  152. public void RequestGoBackTo(string revisionId)
  153. {
  154. RequestedGoBackToCount++;
  155. RequestedGoBackToRevisionId = revisionId;
  156. }
  157. public void ClearError()
  158. {
  159. }
  160. public void RequestShowConflictedDifferences(string path)
  161. {
  162. throw new NotImplementedException();
  163. }
  164. public void RequestChooseMerge(string path)
  165. {
  166. throw new NotImplementedException();
  167. }
  168. public void RequestChooseMine(string[] paths)
  169. {
  170. throw new NotImplementedException();
  171. }
  172. public void RequestChooseRemote(string[] paths)
  173. {
  174. throw new NotImplementedException();
  175. }
  176. public void RequestSync()
  177. {
  178. throw new NotImplementedException();
  179. }
  180. public void RequestCancelJob()
  181. {
  182. throw new NotImplementedException();
  183. }
  184. public void RequestTurnOnService()
  185. {
  186. throw new NotImplementedException();
  187. }
  188. public void ShowServicePage()
  189. {
  190. throw new NotImplementedException();
  191. }
  192. public void ShowLoginPage()
  193. {
  194. throw new NotImplementedException();
  195. }
  196. public void ShowNoSeatPage()
  197. {
  198. throw new NotImplementedException();
  199. }
  200. }
  201. }