Skip to content

Instantly share code, notes, and snippets.

@nulltoken
Created May 8, 2012 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nulltoken/2639280 to your computer and use it in GitHub Desktop.
Save nulltoken/2639280 to your computer and use it in GitHub Desktop.
(LibGit bug?] Surprisingly failing test
[Fact]
public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths()
{
// Initialize a new repository
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
const string directoryName = "directory";
const string fileName = "Testfile.txt";
// Create a file and insert some content
string directoryPath = Path.Combine(scd.RootedDirectoryPath, directoryName);
string filePath = Path.Combine(directoryPath, fileName);
Directory.CreateDirectory(directoryPath);
File.WriteAllText(filePath, "Anybody out there?");
// Open the repository
using (Repository repo = Repository.Init(scd.DirectoryPath))
{
var status = repo.Index.RetrieveStatus(filePath);
status.ShouldEqual(FileStatus.Untracked);
// Add the file to the index
repo.Index.Stage(filePath);
status = repo.Index.RetrieveStatus(filePath);
status.ShouldEqual(FileStatus.Added);
// Get the repository status
RepositoryStatus repoStatus = repo.Index.RetrieveStatus();
repoStatus.Count().ShouldEqual(1);
StatusEntry statusEntry = repoStatus.Single();
string expectedPath = string.Format("{0}{1}{2}", directoryName, Path.DirectorySeparatorChar, fileName);
statusEntry.FilePath.ShouldEqual(expectedPath);
repoStatus.Added.Single().ShouldEqual(statusEntry.FilePath);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment