Exemple #1
0
        public void TestAbsentFileAndDir(RepoConfig repoCfg)
        {
            using var helper = Clone(repoCfg);

            // track a file that doesn't exist
            var dir              = helper.GetPath(@"src\files");
            var absentDir        = helper.GetPath(@"src\files\newSubfolder");
            var absentFile       = helper.GetPath(@"src\files\newSubfolder\newSubfolderFile.txt");
            var dirResult        = helper.TrackDir(dir);
            var absentDirResult  = helper.TrackDir(absentDir);
            var absentFileResult = helper.TrackPath(absentFile);

            XAssert.AreEqual(PathExistence.ExistsAsDirectory, dirResult.Existence);
            XAssert.AreEqual(PathExistence.Nonexistent, absentDirResult.Existence);
            XAssert.AreEqual(PathExistence.Nonexistent, absentFileResult.Existence);

            // switch to a new branch where that file does exist
            using var reseter = helper.GitCheckout("newFileInNewSubfolder");

            // immediately snap changes
            helper.SnapCheckPoint();

            XAssert.FileExists(absentFile);
            XAssert.DirectoryExists(absentDir);

            // assert directory membership changes
            helper.AssertAnyChange(dir, PathChanges.MembershipChanged);
            helper.AssertAnyChange(absentDir, PathChanges.NewlyPresentAsDirectory);
            helper.AssertAnyChange(absentFile, PathChanges.NewlyPresentAsFile);
        }
Exemple #2
0
        public void TestFileBecomesFolder(RepoConfig repoCfg)
        {
            using var helper = Clone(repoCfg);

            // track a folder and a file
            var dir  = helper.GetPath(@"src\files\subfolder");
            var file = helper.GetPath(@"src\files\subfolder\newFile.txt");

            var dirResult  = helper.TrackDir(dir);
            var fileResult = helper.TrackPath(file);

            XAssert.AreEqual(PathExistence.ExistsAsDirectory, dirResult.Existence);
            XAssert.AreEqual(PathExistence.ExistsAsFile, fileResult.Existence);

            // switch to a new branch where that file is now a folder
            using var reseter = helper.GitCheckout("fileBecomesFolder");

            // immediately snap changes
            helper.SnapCheckPoint();

            XAssert.DirectoryExists(file);

            // assert directory membership changes
            helper.AssertAnyChange(dir, PathChanges.MembershipChanged);
            helper.AssertAnyChange(file, PathChanges.Removed);
        }