public void GetChangedFilesTest() { GitRepository.Init(tempFolder); File.WriteAllLines(tempFilePath, lines); GitRepository tracker = new GitRepository(tempFolder); tracker.StageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile)); tracker.Commit("中文 1čtestč"); tracker.Refresh(); Assert.AreEqual(0, tracker.ChangedFiles.Count()); File.WriteAllText(tempFilePath, "a"); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); }
public void GetFileStatusTest() { GitRepository.Init(tempFolder); GitRepository tracker = new GitRepository(tempFolder); File.WriteAllLines(tempFilePath, lines); Assert.AreEqual(GitFileStatus.New, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile)); tracker.UnStageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.New, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Added, tracker.GetFileStatus(tempFile)); tracker.Commit("中文 1čtestč"); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Tracked, tracker.GetFileStatus(tempFile)); File.WriteAllText(tempFilePath, "changed text"); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Staged, tracker.GetFileStatus(tempFile)); tracker.UnStageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); File.Delete(tempFilePath); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Deleted, tracker.GetFileStatus(tempFile)); tracker.StageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Removed, tracker.GetFileStatus(tempFile)); tracker.UnStageFile(tempFile); tracker.Refresh(); Assert.AreEqual(GitFileStatus.Deleted, tracker.GetFileStatus(tempFile)); }
public void FileNameCaseTest() { GitRepository.Init(tempFolder); File.WriteAllLines(tempFilePath, lines); GitRepository tracker = new GitRepository(tempFolder); tracker.StageFile(tempFile); tracker.Commit("test message"); Assert.IsTrue(tracker.LastCommitMessage.StartsWith("test message")); tempFile = tempFile.Replace("test", "TEST"); File.WriteAllText(tempFilePath, "changed text"); tracker.Refresh(); //This test fails all cases because status check uses ngit, never git.exe //Assert.AreEqual(GitFileStatus.Modified, tracker.GetFileStatus(tempFile)); var file = tracker.ChangedFiles.First(); Assert.AreEqual(GitFileStatus.Modified, file.Status); }