public void GivenNewRepository_WhenBare_ThenInitCreatesRefsDirectory() { Gitlet.Init(Bare()); var refsPath = Files.CurrentPath.Combine("refs"); Assert.That(Directory.Exists(refsPath), Is.True); }
public void GivenNewRepository_WhenNotBare_ThenInitCreatesRefsHeadsDirectory() { Gitlet.Init(); var refsHeadsPath = Files.CurrentPath.Combine(".gitlet", "refs", "heads"); Assert.That(Directory.Exists(refsHeadsPath), Is.True); }
public void GivenNewRepository_WhenNotBare_ThenInitCreatesObjectsDirectory() { Gitlet.Init(); var objectsPath = Files.CurrentPath.Combine(".gitlet", "objects"); Assert.That(Directory.Exists(objectsPath), Is.True); }
public void GivenNewRepository_WhenBare_ThenInitCreatesHead() { Gitlet.Init(Bare()); var head = Files.CurrentPath.Combine("HEAD").ReadAllText(); Assert.That(head, Is.EqualTo("ref: refs/heads/master\n")); }
public void GivenNewRepository_WhenBare_ThenInitCreatesConfig() { Gitlet.Init(Bare()); var config = Files.CurrentPath.Combine("config").ReadAllText(); Assert.That(config, Is.EqualTo("[core]\n bare = true\n")); }
public void GivenANewRepository_WhenSpecifiedFileExists_ThenAddCreatesAnObjectFile() { NewRepositoryAssumptions(); Files.CurrentPath.Combine("number.txt").WriteAllText("first!"); Gitlet.Add("number.txt"); var objectFile = Files.CurrentPath.Combine(".gitlet", "objects", Util.Hash("first!")).ReadAllText(); Assert.That(objectFile, Is.EqualTo("first!")); }
public void GivenANewRepository_WhenSpecifiedFileExists_ThenAddCreatesIndex() { NewRepositoryAssumptions(); Files.CurrentPath.Combine("number.txt").WriteAllText("first!"); Gitlet.Add("number.txt"); var index = Files.CurrentPath.Combine(".gitlet", "index").ReadAllText(); var expectedIndex = string.Format("number.txt 0 {0}\n", Util.Hash("first!")); Assert.That(index, Is.EqualTo(expectedIndex)); }
public void GivenExistingRepository_ThenInitThrowException() { Gitlet.Init(); Assert.That(() => Gitlet.Init(), Throws.Exception.With.Message.EqualTo("unsupported")); }
public static void Init() { Gitlet.Init(); }
public static void FirstAdd() { Files.CurrentPath.Combine("number.txt").WriteAllText("first!"); Gitlet.Add("number.txt"); }
public void GivenANewRepository_WhenSpecifiedFileDoesNotExists_ThenAddThrowsException() { NewRepositoryAssumptions(); Assert.That(() => Gitlet.Add("number.txt"), Throws.Exception.With.Message.ContainsSubstring("did not match any files")); }