|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
| 3 | +using System.Windows.Forms; |
3 | 4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
4 | 5 | using Rubberduck.UI.SourceControl;
|
5 | 6 | using Rubberduck.SourceControl;
|
@@ -115,5 +116,39 @@ public void ChangesToViewAreRevertedOnCancel()
|
115 | 116 | Assert.AreEqual(Email, _view.Object.EmailAddress, "Email");
|
116 | 117 | Assert.AreEqual(RepoLocation, _view.Object.DefaultRepositoryLocation, "Default Repo Location");
|
117 | 118 | }
|
| 119 | + |
| 120 | + [TestMethod] |
| 121 | + public void OnBrowseDefaultRepoLocation_WhenUserConfirms_ViewMatchesSelectedPath() |
| 122 | + { |
| 123 | + //arrange |
| 124 | + _view.Object.DefaultRepositoryLocation = RepoLocation; |
| 125 | + _folderBrowser.Object.SelectedPath = OtherRepoLocation; |
| 126 | + _folderBrowser.Setup(f => f.ShowDialog()).Returns(DialogResult.OK); |
| 127 | + |
| 128 | + var presenter = new SettingsPresenter(_view.Object, _configService.Object, _folderBrowserFactory.Object); |
| 129 | + |
| 130 | + //act |
| 131 | + _view.Raise(v => v.BrowseDefaultRepositoryLocation +=null, EventArgs.Empty); |
| 132 | + |
| 133 | + //assert |
| 134 | + Assert.AreEqual(_folderBrowser.Object.SelectedPath, _view.Object.DefaultRepositoryLocation); |
| 135 | + } |
| 136 | + |
| 137 | + [TestMethod] |
| 138 | + public void OnBrowserDefaultRepoLocation_WhenUserCancels_ViewRemainsUnchanged() |
| 139 | + { |
| 140 | + //arrange |
| 141 | + _view.Object.DefaultRepositoryLocation = RepoLocation; |
| 142 | + _folderBrowser.Object.SelectedPath = OtherRepoLocation; |
| 143 | + _folderBrowser.Setup(f => f.ShowDialog()).Returns(DialogResult.Cancel); |
| 144 | + |
| 145 | + var presenter = new SettingsPresenter(_view.Object, _configService.Object, _folderBrowserFactory.Object); |
| 146 | + |
| 147 | + //act |
| 148 | + _view.Raise(v => v.BrowseDefaultRepositoryLocation += null, EventArgs.Empty); |
| 149 | + |
| 150 | + //assert |
| 151 | + Assert.AreEqual(RepoLocation, _view.Object.DefaultRepositoryLocation); |
| 152 | + } |
118 | 153 | }
|
119 | 154 | }
|
0 commit comments