PageRenderTime 38ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/IntegrationTests/UI.IntegrationTests/CommandsDialogs/FormRebaseTests.cs

https://github.com/gitextensions/gitextensions
C# | 201 lines | 172 code | 29 blank | 0 comment | 1 complexity | 76d7ca25361987c8ad83fd2a5b5b2efe MD5 | raw file
Possible License(s): GPL-3.0
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. using CommonTestUtils;
  5. using FluentAssertions;
  6. using GitUI;
  7. using GitUI.CommandsDialogs;
  8. using NUnit.Framework;
  9. namespace GitExtensions.UITests.CommandsDialogs
  10. {
  11. [Apartment(ApartmentState.STA)]
  12. public class FormRebaseTests
  13. {
  14. private ReferenceRepository _referenceRepository;
  15. private GitUICommands _commands;
  16. [SetUp]
  17. public void SetUp()
  18. {
  19. if (_referenceRepository is null)
  20. {
  21. _referenceRepository = new ReferenceRepository();
  22. }
  23. else
  24. {
  25. _referenceRepository.Reset();
  26. }
  27. _commands = new GitUICommands(_referenceRepository.Module);
  28. }
  29. [Test]
  30. public void Interactive_check_enables_autosquash()
  31. {
  32. RunFormTest(
  33. form =>
  34. {
  35. var accessor = form.GetTestAccessor();
  36. accessor.chkInteractive.Checked = true;
  37. accessor.chkAutosquash.Enabled.Should().BeTrue();
  38. },
  39. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  40. }
  41. [Test]
  42. public void Interactive_uncheck_disables_autosquash()
  43. {
  44. RunFormTest(
  45. form =>
  46. {
  47. var accessor = form.GetTestAccessor();
  48. accessor.chkInteractive.Checked = true;
  49. accessor.chkInteractive.Checked = false;
  50. accessor.chkAutosquash.Enabled.Should().BeFalse();
  51. },
  52. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  53. }
  54. [Test]
  55. public void Ignore_date_check_disables_all_other_options()
  56. {
  57. RunFormTest(
  58. form =>
  59. {
  60. var accessor = form.GetTestAccessor();
  61. accessor.chkIgnoreDate.Checked = true;
  62. accessor.chkInteractive.Enabled.Should().BeFalse();
  63. accessor.chkPreserveMerges.Enabled.Should().BeFalse();
  64. accessor.chkAutosquash.Enabled.Should().BeFalse();
  65. accessor.chkCommitterDateIsAuthorDate.Enabled.Should().BeFalse();
  66. },
  67. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  68. }
  69. [Test]
  70. public void Ignore_date_uncheck_enables_all_options_if_interactive_checked()
  71. {
  72. RunFormTest(
  73. form =>
  74. {
  75. var accessor = form.GetTestAccessor();
  76. accessor.chkInteractive.Checked = true;
  77. accessor.chkIgnoreDate.Checked = true;
  78. accessor.chkIgnoreDate.Checked = false;
  79. accessor.chkInteractive.Enabled.Should().BeTrue();
  80. accessor.chkPreserveMerges.Enabled.Should().BeTrue();
  81. accessor.chkAutosquash.Enabled.Should().BeTrue();
  82. accessor.chkCommitterDateIsAuthorDate.Enabled.Should().BeTrue();
  83. },
  84. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  85. }
  86. [Test]
  87. public void Ignore_date_uncheck_enables_all_options_but_autosquash_if_interactive_not_checked()
  88. {
  89. RunFormTest(
  90. form =>
  91. {
  92. var accessor = form.GetTestAccessor();
  93. accessor.chkIgnoreDate.Checked = true;
  94. accessor.chkIgnoreDate.Checked = false;
  95. accessor.chkInteractive.Enabled.Should().BeTrue();
  96. accessor.chkPreserveMerges.Enabled.Should().BeTrue();
  97. accessor.chkAutosquash.Enabled.Should().BeFalse();
  98. accessor.chkCommitterDateIsAuthorDate.Enabled.Should().BeTrue();
  99. },
  100. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  101. }
  102. [Test]
  103. public void Committer_date_check_disables_all_other_options()
  104. {
  105. RunFormTest(
  106. form =>
  107. {
  108. var accessor = form.GetTestAccessor();
  109. accessor.chkCommitterDateIsAuthorDate.Checked = true;
  110. accessor.chkInteractive.Enabled.Should().BeFalse();
  111. accessor.chkPreserveMerges.Enabled.Should().BeFalse();
  112. accessor.chkAutosquash.Enabled.Should().BeFalse();
  113. accessor.chkIgnoreDate.Enabled.Should().BeFalse();
  114. },
  115. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  116. }
  117. [Test]
  118. public void Committer_date_uncheck_enables_all_options_if_interactive_is_checked()
  119. {
  120. RunFormTest(
  121. form =>
  122. {
  123. var accessor = form.GetTestAccessor();
  124. accessor.chkInteractive.Checked = true;
  125. accessor.chkCommitterDateIsAuthorDate.Checked = true;
  126. accessor.chkCommitterDateIsAuthorDate.Checked = false;
  127. accessor.chkInteractive.Enabled.Should().BeTrue();
  128. accessor.chkPreserveMerges.Enabled.Should().BeTrue();
  129. accessor.chkAutosquash.Enabled.Should().BeTrue();
  130. accessor.chkIgnoreDate.Enabled.Should().BeTrue();
  131. },
  132. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  133. }
  134. [Test]
  135. public void Committer_date_uncheck_enables_all_options_but_autosquash_if_interactive_not_checked()
  136. {
  137. RunFormTest(
  138. form =>
  139. {
  140. var accessor = form.GetTestAccessor();
  141. accessor.chkCommitterDateIsAuthorDate.Checked = true;
  142. accessor.chkCommitterDateIsAuthorDate.Checked = false;
  143. accessor.chkInteractive.Enabled.Should().BeTrue();
  144. accessor.chkPreserveMerges.Enabled.Should().BeTrue();
  145. accessor.chkAutosquash.Enabled.Should().BeFalse();
  146. accessor.chkIgnoreDate.Enabled.Should().BeTrue();
  147. },
  148. from: "", to: null, onto: null, interactive: false, startRebaseImmediately: false);
  149. }
  150. private void RunFormTest(Action<FormRebase> testDriver, string from, string to, string onto,
  151. bool interactive, bool startRebaseImmediately)
  152. {
  153. RunFormTest(
  154. form =>
  155. {
  156. testDriver(form);
  157. return Task.CompletedTask;
  158. },
  159. from, to, onto, interactive, startRebaseImmediately);
  160. }
  161. private void RunFormTest(Func<FormRebase, Task> testDriverAsync, string from, string to,
  162. string onto, bool interactive, bool startRebaseImmediately)
  163. {
  164. UITest.RunForm(
  165. () =>
  166. {
  167. _commands.StartRebaseDialog(owner: null, from, to, onto, interactive, startRebaseImmediately);
  168. },
  169. testDriverAsync);
  170. }
  171. }
  172. }