Skip to content

Commit ecc6514

Browse files
authored
Merge branch 'next' into Issue1770
2 parents edde103 + 6762d6b commit ecc6514

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,4 +1647,10 @@ All our stargazers, likers & followers, for the warm fuzzies
16471647
<data name="SourceControl_OpenCommandPromptFailureTitle" xml:space="preserve">
16481648
<value>Failure opening command prompt</value>
16491649
</data>
1650+
<data name="SourceControl_ActivateProject" xml:space="preserve">
1651+
<value>Please open or activate a project and try again.</value>
1652+
</data>
1653+
<data name="SourceControl_NoActiveProject" xml:space="preserve">
1654+
<value>No active VBProject</value>
1655+
</data>
16501656
</root>

RetailCoder.VBE/UI/SourceControl/SourceControlViewViewModel.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,11 +818,18 @@ private bool ValidRepoExists()
818818
return false;
819819
}
820820

821-
var possibleRepos = _config.Repositories.Where(repo => repo.Id == _vbe.ActiveVBProject.HelpFile);
822-
var possibleCount = possibleRepos.Count();
821+
var project = _vbe.ActiveVBProject ?? (_vbe.VBProjects.Count == 1 ? _vbe.VBProjects.Item(1) : null);
823822

824-
//todo: if none are found, prompt user to create one
825-
return possibleCount == 1;
823+
if (project != null)
824+
{
825+
var possibleRepos = _config.Repositories.Where(repo => repo.Id == _vbe.ActiveVBProject.HelpFile);
826+
return possibleRepos.Count() == 1;
827+
}
828+
829+
ViewModel_ErrorThrown(this,
830+
new ErrorEventArgs(RubberduckUI.SourceControl_NoActiveProject,
831+
RubberduckUI.SourceControl_ActivateProject, NotificationType.Error));
832+
return false;
826833
}
827834

828835
private void ShowFilePicker()

RubberduckTests/SourceControl/SourceControlViewModelTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,22 @@ public void OnBrowseDefaultRepoLocation_WhenUserCancels_LocalDirectoryDoesNotCha
975975
Assert.AreEqual(originalPath, _vm.LocalDirectory);
976976
}
977977

978+
[TestMethod]
979+
public void NullProject_DisplaysError()
980+
{
981+
//arrange
982+
SetupValidVbProject();
983+
SetupVM();
984+
_vbe.Setup(v => v.ActiveVBProject).Returns((VBProject)null);
985+
_vbe.Setup(v => v.VBProjects).Returns(new Mock<VBProjects>().Object);
986+
987+
//act
988+
_vm.RefreshCommand.Execute(null);
989+
990+
//assert
991+
Assert.IsTrue(_vm.DisplayErrorMessageGrid, "Null ActiveProject did not raise error.");
992+
}
993+
978994
private const string DummyRepoId = "SourceControlTest";
979995

980996
private SourceControlSettings GetDummyConfig()

0 commit comments

Comments
 (0)