Esempio n. 1
0
        public void AddingRepositoryWithinAnotherRepositoryWithEmptyStringDirectoryThrows()
        {
            using (var tempParent = new TemporaryFolder("ChorusParent"))
            {
                var parentRepo = new HgRepository(tempParent.Path, new NullProgress());
                parentRepo.Init();
                var parentFile = tempParent.GetNewTempFile(true);
                File.WriteAllText(parentFile.Path, "New Content");
                parentRepo.AddAndCheckinFile(parentFile.Path);

                Assert.Throws<ArgumentNullException>(() => HgRepository.CreateOrUseExisting("", new NullProgress()));
            }
        }
Esempio n. 2
0
        public void AddingRepositoryWithinAnotherRepositoryWithNonexistantDirectoryThrows()
        {
            using (var tempParent = new TemporaryFolder("ChorusParent"))
            {
                var parentRepo = new HgRepository(tempParent.Path, new NullProgress());
                parentRepo.Init();
                var parentFile = tempParent.GetNewTempFile(true);
                File.WriteAllText(parentFile.Path, "New Content");
                parentRepo.AddAndCheckinFile(parentFile.Path);

                var parentFolder = tempParent.Path;
                var nonexistantDirectory = Path.Combine(parentFolder, "Child");
                Assert.Throws<InvalidOperationException>(() => HgRepository.CreateOrUseExisting(nonexistantDirectory, new NullProgress()));
            }
        }
Esempio n. 3
0
        public void AddingRepositoryWithinAnotherRepositoryFromDirectoryNameIsDifferentRepository()
        {
            using (var tempParent = new TemporaryFolder("ChorusParent"))
            {
                var parentRepo = new HgRepository(tempParent.Path, new NullProgress());
                parentRepo.Init();
                var parentFile = tempParent.GetNewTempFile(true);
                File.WriteAllText(parentFile.Path, "New Content");
                parentRepo.AddAndCheckinFile(parentFile.Path);

                var parentFolder = tempParent.Path;
                var dirInfo = Directory.CreateDirectory(Path.Combine(parentFolder, "Child"));
                var childRepo = HgRepository.CreateOrUseExisting(dirInfo.FullName, new NullProgress());
                Assert.AreNotEqual(parentFolder, childRepo.PathToRepo);
            }
        }
Esempio n. 4
0
 public void GetRevisionWorkingSetIsBasedOn_OneCheckin_Gives0()
 {
     using (var testRoot = new TemporaryFolder("ChorusHgWrappingTest"))
     {
         HgRepository.CreateRepositoryInExistingDir(testRoot.Path, _progress);
         var repo = new HgRepository(testRoot.Path, new NullProgress());
         using(var f = testRoot.GetNewTempFile(true))
         {
             repo.AddAndCheckinFile(f.Path);
             var rev = repo.GetRevisionWorkingSetIsBasedOn();
             Assert.AreEqual("0", rev.Number.LocalRevisionNumber);
             Assert.AreEqual(12, rev.Number.Hash.Length);
         }
     }
 }
		public void DirectoryIsEmpty_DirectoryContainsFile()
		{
			using (var tempDir = new TemporaryFolder("IsEmpty_DirectoryContainsFile"))
			{
				var file = tempDir.GetNewTempFile(false);
				File.WriteAllText(file.Path, @"Some test text");
				Assert.IsFalse(DirectoryUtilities.DirectoryIsEmpty(tempDir.Path));
				Assert.IsFalse(DirectoryUtilities.DirectoryIsEmpty(tempDir.Path, true));
			}
		}
		public void Setup()
		{
			_tempfolder = new TemporaryFolder("LiftLexEntryRepositoryCachingTests");
			_tempFile = _tempfolder.GetNewTempFile(true);
			_repository = new LiftLexEntryRepository(_tempFile.Path);
		}
Esempio n. 7
0
 public void RepositoryRecoversFromIncompleteMerge()
 {
     using (var tempRepo = new TemporaryFolder("ChorusIncompleteMerge"))
     {
         var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
     #if MONO
         baseDir = baseDir.Replace(@"file:", null);
     #else
         baseDir = baseDir.Replace(@"file:\", null);
     #endif
         var zipFile = new ZipFile(Path.Combine(baseDir, Path.Combine("VcsDrivers", Path.Combine("TestData", "incompletemergerepo.zip"))));
         zipFile.ExtractAll(tempRepo.Path);
         var hgRepo = new HgRepository(tempRepo.Path, new NullProgress());
         hgRepo.CheckAndUpdateHgrc();
         var parentFile = tempRepo.GetNewTempFile(true);
         File.WriteAllText(parentFile.Path, "New Content");
         var exception = Assert.Throws<ApplicationException>(() => hgRepo.AddAndCheckinFile(parentFile.Path));
         Assert.That(exception.Message.Contains("Unable to recover") && !exception.Message.Contains("unresolved merge"),
             String.Format("Repository should have conflict in retrying the merge, but not have an incomplete merge: {0}", exception.Message));
     }
 }