Skip to content

Commit 4e7a563

Browse files
committed
More tests
1 parent be912d5 commit 4e7a563

File tree

2 files changed

+202
-31
lines changed

2 files changed

+202
-31
lines changed

RubberduckTests/SourceControl/BranchesViewModelTests.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,31 @@ public void OnBranchChange_WhenCheckoutFails_ActionFailedEventIsRaised()
708708
Assert.IsTrue(wasRaised, "ActionFailedEvent was not raised.");
709709
}
710710

711+
[TestMethod]
712+
public void OnMergeBranch_WhenCheckoutFails_ActionFailedEventIsRaised()
713+
{
714+
//arrange
715+
var vm = new BranchesViewViewModel
716+
{
717+
Provider = _provider.Object
718+
};
719+
var wasRaised = false;
720+
721+
_provider.Setup(p => p.Merge(It.IsAny<string>(), It.IsAny<string>()))
722+
.Throws(
723+
new SourceControlException("A source control exception was thrown.",
724+
new LibGit2Sharp.LibGit2SharpException("With an inner libgit2sharp exception"))
725+
);
726+
727+
vm.ErrorThrown += (sender, error) => wasRaised = true;
728+
729+
//act
730+
vm.MergeBranchesOkButtonCommand.Execute(null);
731+
732+
//assert
733+
Assert.IsTrue(wasRaised, "ActionFailedEvent was not raised.");
734+
}
735+
711736
[TestMethod]
712737
public void OnDeleteBranch_WhenDeleteFails_ActionFailedEventIsRaised()
713738
{
@@ -795,5 +820,55 @@ public void UnpublishUnpublishesBranch()
795820
//Assert
796821
_provider.Verify(git => git.Unpublish(branch));
797822
}
823+
824+
[TestMethod]
825+
public void PublishBranch_ActionFailedEventIsRaised()
826+
{
827+
//arrange
828+
var vm = new BranchesViewViewModel
829+
{
830+
Provider = _provider.Object
831+
};
832+
var wasRaised = false;
833+
834+
_provider.Setup(p => p.Publish(It.IsAny<string>()))
835+
.Throws(
836+
new SourceControlException("A source control exception was thrown.",
837+
new LibGit2Sharp.LibGit2SharpException("With an inner libgit2sharp exception"))
838+
);
839+
840+
vm.ErrorThrown += (sender, error) => wasRaised = true;
841+
842+
//act
843+
vm.PublishBranchToolbarButtonCommand.Execute(null);
844+
845+
//assert
846+
Assert.IsTrue(wasRaised, "ActionFailedEvent was not raised.");
847+
}
848+
849+
[TestMethod]
850+
public void UnpublishBranch_ActionFailedEventIsRaised()
851+
{
852+
//arrange
853+
var vm = new BranchesViewViewModel
854+
{
855+
Provider = _provider.Object
856+
};
857+
var wasRaised = false;
858+
859+
_provider.Setup(p => p.Unpublish(It.IsAny<string>()))
860+
.Throws(
861+
new SourceControlException("A source control exception was thrown.",
862+
new LibGit2Sharp.LibGit2SharpException("With an inner libgit2sharp exception"))
863+
);
864+
865+
vm.ErrorThrown += (sender, error) => wasRaised = true;
866+
867+
//act
868+
vm.UnpublishBranchToolbarButtonCommand.Execute("master");
869+
870+
//assert
871+
Assert.IsTrue(wasRaised, "ActionFailedEvent was not raised.");
872+
}
798873
}
799874
}

0 commit comments

Comments
 (0)