Exemplo n.º 1
0
        public void Create_Repo_Add_Files_Check_Head()
        {
            var nGit = new API_NGit();
            var tempRepo = "_tempRepo".tempDir(true);
            "TestRepo is: {0}".info(tempRepo);
            //Creating a local temp Repo
            Assert.IsFalse(tempRepo.isGitRepository() , "Should not be a repo");
            nGit.init(tempRepo);
            Assert.IsTrue(tempRepo.isGitRepository(), "Should be a repo");
            Assert.IsNull(nGit.head());

            //Adding a file (using method 1)
            nGit.file_Create("testFile.txt", "some Text");
            nGit.add_and_Commit_using_Status();
            var head1 = nGit.head();
            Assert.IsNotNull(head1);

            //Adding another file (using method 2)
            nGit.file_Create("testFile2.txt", "some Text");
            nGit.add("testFile2.txt");
            nGit.commit("Adding Another file");

            //making sure the head has changed
            var head2 = nGit.head();
            Assert.AreNotEqual(head1,head2);

            nGit.delete_Repository_And_Files();
        }
Exemplo n.º 2
0
        public void init()
        {
            //git_Init();    // already triggers methods funcionality

            //test Exception handing (by creating a .git file (which should be a folder))
            var tempDir      = "tempDir".tempDir();
            var fakeGitFolder = tempDir.pathCombine(".git");
            Assert.IsTrue(tempDir.dirExists());
            Assert.IsFalse(tempDir.isGitRepository());

            "aaa".saveAs(fakeGitFolder);  //

            Assert.IsFalse(tempDir.isGitRepository());
            var nGit = new API_NGit();
            var result = nGit.init(tempDir);

            Assert.IsFalse(tempDir.isGitRepository());
            Assert.IsNull(result);
            Assert.IsInstanceOf<JGitInternalException>(nGit.Last_Exception);
            tempDir.delete_Folder();
            Assert.IsFalse(tempDir.dirExists());
        }