public void ExceptionIfNegativeNumberOfThreads() { string orgRepoPath = SandboxPackBuilderTestRepo(); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath); Assert.Throws <ArgumentException>(() => { packBuilderOptions.MaximumNumberOfThreads = -1; }); }
public void ExceptionIfNegativeNumberOfThreads() { string orgRepoPath = SandboxPackBuilderTestRepo(); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath); Assert.Throws<ArgumentException>(() => { packBuilderOptions.MaximumNumberOfThreads = -1; }); }
public void ExceptionIfBuildDelegateEqualsNull() { string orgRepoPath = SandboxPackBuilderTestRepo(); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath); using (Repository orgRepo = new Repository(orgRepoPath)) { Assert.Throws <ArgumentNullException>(() => { orgRepo.ObjectDatabase.Pack(packBuilderOptions, null); }); } }
public void ExceptionIfBuildDelegateEqualsNull() { string orgRepoPath = SandboxPackBuilderTestRepo(); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath); using (Repository orgRepo = new Repository(orgRepoPath)) { Assert.Throws<ArgumentNullException>(() => { orgRepo.ObjectDatabase.Pack(packBuilderOptions, null); }); } }
public void ExceptionIfAddRecursivelyNullObjectID() { string orgRepoPath = SandboxPackBuilderTestRepo(); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath); using (Repository orgRepo = new Repository(orgRepoPath)) { Assert.Throws <ArgumentNullException>(() => { orgRepo.ObjectDatabase.Pack(packBuilderOptions, builder => { builder.AddRecursively(null); }); }); } }
public void ExceptionIfAddRecursivelyNullObjectID() { string orgRepoPath = SandboxPackBuilderTestRepo(); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(orgRepoPath); using (Repository orgRepo = new Repository(orgRepoPath)) { Assert.Throws<ArgumentNullException>(() => { orgRepo.ObjectDatabase.Pack(packBuilderOptions, builder => { builder.AddRecursively(null); }); }); } }
internal void TestIfSameRepoAfterPacking(Action <IRepository, PackBuilder> packDelegate) { // read a repo // pack with the provided action // write the pack file in a mirror repo // read new repo // compare string orgRepoPath = SandboxPackBuilderTestRepo(); string mrrRepoPath = SandboxPackBuilderTestRepo(); string mrrRepoPackDirPath = Path.Combine(mrrRepoPath + "/.git/objects"); DirectoryHelper.DeleteDirectory(mrrRepoPackDirPath); Directory.CreateDirectory(mrrRepoPackDirPath + "/pack"); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(mrrRepoPackDirPath + "/pack"); using (Repository orgRepo = new Repository(orgRepoPath)) { PackBuilderResults results; if (packDelegate != null) { results = orgRepo.ObjectDatabase.Pack(packBuilderOptions, b => packDelegate(orgRepo, b)); } else { results = orgRepo.ObjectDatabase.Pack(packBuilderOptions); } // written objects count is the same as in objects database Assert.Equal(orgRepo.ObjectDatabase.Count(), results.WrittenObjectsCount); // loading a repo from the written pack file. using (Repository mrrRepo = new Repository(mrrRepoPath)) { // make sure the objects of the original repo are the same as the ones in the mirror repo // doing that by making sure the count is the same, and the set difference is empty Assert.True(mrrRepo.ObjectDatabase.Count() == orgRepo.ObjectDatabase.Count() && !mrrRepo.ObjectDatabase.Except(orgRepo.ObjectDatabase).Any()); Assert.Equal(orgRepo.Commits.Count(), mrrRepo.Commits.Count()); Assert.Equal(orgRepo.Branches.Count(), mrrRepo.Branches.Count()); Assert.Equal(orgRepo.Refs.Count(), mrrRepo.Refs.Count()); } } }
internal void TestIfSameRepoAfterPacking(Action<IRepository, PackBuilder> packDelegate) { // read a repo // pack with the provided action // write the pack file in a mirror repo // read new repo // compare string orgRepoPath = SandboxPackBuilderTestRepo(); string mrrRepoPath = SandboxPackBuilderTestRepo(); string mrrRepoPackDirPath = Path.Combine(mrrRepoPath + "/.git/objects"); DirectoryHelper.DeleteDirectory(mrrRepoPackDirPath); Directory.CreateDirectory(mrrRepoPackDirPath + "/pack"); PackBuilderOptions packBuilderOptions = new PackBuilderOptions(mrrRepoPackDirPath + "/pack"); using (Repository orgRepo = new Repository(orgRepoPath)) { PackBuilderResults results; if (packDelegate != null) results = orgRepo.ObjectDatabase.Pack(packBuilderOptions, b => packDelegate(orgRepo, b)); else results = orgRepo.ObjectDatabase.Pack(packBuilderOptions); // written objects count is the same as in objects database Assert.Equal(orgRepo.ObjectDatabase.Count(), results.WrittenObjectsCount); // loading a repo from the written pack file. using (Repository mrrRepo = new Repository(mrrRepoPath)) { // make sure the objects of the original repo are the same as the ones in the mirror repo // doing that by making sure the count is the same, and the set difference is empty Assert.True(mrrRepo.ObjectDatabase.Count() == orgRepo.ObjectDatabase.Count() && !mrrRepo.ObjectDatabase.Except(orgRepo.ObjectDatabase).Any()); Assert.Equal(orgRepo.Commits.Count(), mrrRepo.Commits.Count()); Assert.Equal(orgRepo.Branches.Count(), mrrRepo.Branches.Count()); Assert.Equal(orgRepo.Refs.Count(), mrrRepo.Refs.Count()); } } }