public void FetchRebaseBranchesSingleMatchingRemoteBranchTest() { // Prepare var mock = new Mock <ICommandRunner>(); var localBranchInfo = "*dev"; var remoteBranchInfo = $"*master{Environment.NewLine}dev"; mock.Setup(f => f.Run("git", "branch -l --no-color", out localBranchInfo)) .Returns(0); mock.Setup(f => f.Run("git", "branch -r --no-color", out remoteBranchInfo)) .Returns(0); var options = new Options() { RebaseBranch = "dev" }; var expected = new List <string>(new string[] { "dev" }); IGrabber grabber = CreateGrabber(options, mock.Object); // Act grabber.FetchRebaseBraches(); var actual = grabber.GetMetaInfo().LocalBranches; // Assert Assert.Equal(expected, actual); }
public void GetMetaInfoTest() { // Prepare var mock = new Mock <ICommandRunner>(); Options options = new Options() { SubpathToTrunk = "subpath", IncludeMetaData = true, NoBranches = false, NoTags = false, RootIsTrunk = false, Exclude = new List <string>() { "ex1", "ex2" }, Tags = new List <string>() { "tag1", "tag2" }, Branches = new List <string>() { "branch1", "branch2" } }; var standardOutput = "*branch1"; mock.Setup(f => f.Run("git", "branch -l --no-color", out standardOutput)) .Returns(0); standardOutput = "svn/tags/branch2"; mock.Setup(f => f.Run("git", "branch -r --no-color", out standardOutput)) .Returns(0); IGrabber grabber = CreateGrabber(options, mock.Object); // Act grabber.FetchBranches(); var actual = grabber.GetMetaInfo(); // Assert Assert.Equal(new List <string>() { "svn/tags/branch2" }, actual.Tags); Assert.Equal(new List <string>() { "branch1" }, actual.LocalBranches); Assert.Equal(new List <string>() { "svn/tags/branch2" }, actual.RemoteBranches); }
public void FetchBranchesOneRemoteBranchTest() { // Prepare var mock = new Mock <ICommandRunner>(); var standardOutput = "origin/master"; mock.Setup(f => f.Run("git", "branch -r --no-color", out standardOutput)) .Returns(0); IGrabber grabber = CreateGrabber(new Options(), mock.Object); List <string> expected = new List <string>(new string[] { "origin/master" }); // Act grabber.FetchBranches(); var actual = grabber.GetMetaInfo().RemoteBranches; // Assert Assert.Equal(expected, actual); }
public void FetchBranchesHasOneTagTest() { // Prepare var mock = new Mock <ICommandRunner>(); var standardOutput = $"origin/master{Environment.NewLine}origin/dev{Environment.NewLine}svn/tags/v1.0.0"; mock.Setup(f => f.Run("git", "branch -r --no-color", out standardOutput)) .Returns(0); IGrabber grabber = CreateGrabber(new Options(), mock.Object); List <string> expected = new List <string>(new string[] { "svn/tags/v1.0.0" }); // Act grabber.FetchBranches(); var actual = grabber.GetMetaInfo().Tags; // Assert Assert.Equal(expected, actual); }
public void FetchBranchesMultipleLocalBranchesTest() { // Prepare var mock = new Mock <ICommandRunner>(); var standardOutput = $"*master{Environment.NewLine}dev{Environment.NewLine}test"; mock.Setup(f => f.Run("git", "branch -l --no-color", out standardOutput)) .Returns(0); IGrabber grabber = CreateGrabber(new Options(), mock.Object); List <string> expected = new List <string>(new string[] { "master", "dev", "test" }); // Act grabber.FetchBranches(); var actual = grabber.GetMetaInfo().LocalBranches; // Assert Assert.Equal(expected, actual); }