示例#1
0
        public void Test_ALL()
        {
            DirectoryInfo rootDire = new DirectoryInfo(rootDirePath);

            // 未完全实现
            if (Directory.Exists(rootDirePath))
            {
                DirectoryInfo[] haveDires = rootDire.GetDirectories();
                for (int i = 0; i < haveDires.Length; i++)
                {
                    haveDires[i].Delete(true);
                }
                FileInfo[] havefiles = rootDire.GetFiles();
                for (int i = 0; i < havefiles.Length; i++)
                {
                    havefiles[i].Delete();
                }
            }
            else
            {
                Directory.CreateDirectory(rootDirePath);
            }

            IGit git = new GitCommands(new Repository()
            {
                RootPath = new DirectoryInfo(rootDirePath),
            });

            git.Init().OnCommand();
            Assert.AreEqual(true, Directory.Exists(rootDirePath));
            Assert.AreEqual(true, Directory.Exists(Path.Combine(rootDirePath, ".git")));

            string json = JsonConvert.SerializeObject(new { });

            File.WriteAllText(Path.Combine(rootDirePath, "1.json"), json);

            git.Add().OnCommand("1.json");

            IList <string> msgs;

            msgs = git.Status().OnCommand();
            msgs.Test(new string[] {
                "On branch master",
                "No commits yet",
                "Changes to be committed:",
                "  (use \"git rm --cached <file>...\" to unstage)",
                "        new file:   1.json",
            });

            git.Commit().OnCommand("save data");
            msgs = git.Status().OnCommand();
            msgs.Test(new string[] {
                "On branch master",
                "nothing to commit, working tree clean",
            });
        }