public void IfPathIsInvalid_MustReturnAnEmptyString(string path) { var branchGetter = new BranchGetter(); string branchName = branchGetter.GetCurrentBranchName(path); Assert.AreEqual(string.Empty, branchName); }
public void IfGitFolderDoesNotHaveAHeadFile_MustReturnAnEmptyString() { DirectoryInfo gitFolder = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test2", ".git")); var branchGetter = new BranchGetter(); string branchName = branchGetter.GetCurrentBranchName(gitFolder.FullName); Assert.AreEqual(string.Empty, branchName); }
public void IfPathIsNotAGitRepo_MustReturnAnEmptyString() { DirectoryInfo folder = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test1")); var branchGetter = new BranchGetter(); string branchName = branchGetter.GetCurrentBranchName(folder.FullName); Assert.AreEqual(string.Empty, branchName); }
public void IfCurrentBranchBelongsToATree_MustReturnTheFullNameOfTheCurrentBranch() { DirectoryInfo path = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test4")); DirectoryInfo gitFolder = Directory.CreateDirectory(Path.Combine(path.FullName, ".git")); using (StreamWriter file = new StreamWriter(Path.Combine(gitFolder.FullName, "HEAD"), false)) { file.WriteLine("ref: refs/heads/feature/develop123"); } var branchGetter = new BranchGetter(); string branchName = branchGetter.GetCurrentBranchName(path.FullName); Assert.AreEqual("feature/develop123", branchName); }
public void IfTheGitReferencesFolderIsInAParentDirectory_MustReturnTheFullNameOfTheCurrentBranch() { DirectoryInfo path = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test5")); DirectoryInfo gitFolder = Directory.CreateDirectory(Path.Combine(path.FullName, ".git")); using (StreamWriter file = new StreamWriter(Path.Combine(gitFolder.FullName, "HEAD"), false)) { file.WriteLine("ref: refs/heads/feature/develop123"); } DirectoryInfo subFolder = Directory.CreateDirectory(Path.Combine(baseTestPath, "Test5", "Sub1", "Sub2")); var branchGetter = new BranchGetter(); string branchName = branchGetter.GetCurrentBranchName(subFolder.FullName); Assert.AreEqual("feature/develop123", branchName); }