Skip to content

Commit 10f61dd

Browse files
committed
added some missing settings presenter tests
1 parent b13d4a5 commit 10f61dd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

RubberduckTests/SourceControl/SettingsPresenterTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Windows.Forms;
34
using Microsoft.VisualStudio.TestTools.UnitTesting;
45
using Rubberduck.UI.SourceControl;
56
using Rubberduck.SourceControl;
@@ -115,5 +116,39 @@ public void ChangesToViewAreRevertedOnCancel()
115116
Assert.AreEqual(Email, _view.Object.EmailAddress, "Email");
116117
Assert.AreEqual(RepoLocation, _view.Object.DefaultRepositoryLocation, "Default Repo Location");
117118
}
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+
}
118153
}
119154
}

0 commit comments

Comments
 (0)