public void GetAllEntriesSplitsFilesAndFoldersCorrectly() { ConfigurableFileSystem fs = new ConfigurableFileSystem(); using (LegacyPlaceholderListDatabase dut1 = CreatePlaceholderListDatabase(fs, string.Empty)) { dut1.AddFile(InputGitIgnorePath, InputGitIgnoreSHA); dut1.AddPartialFolder("partialFolder"); dut1.AddFile(InputGitAttributesPath, InputGitAttributesSHA); dut1.AddExpandedFolder("expandedFolder"); dut1.AddFile(InputThirdFilePath, InputThirdFileSHA); dut1.AddPossibleTombstoneFolder("tombstone"); dut1.Remove(InputThirdFilePath); } string error; LegacyPlaceholderListDatabase dut2; LegacyPlaceholderListDatabase.TryCreate(null, MockEntryFileName, fs, out dut2, out error).ShouldEqual(true, error); List <IPlaceholderData> fileData; List <IPlaceholderData> folderData; dut2.GetAllEntries(out fileData, out folderData); fileData.Count.ShouldEqual(2); folderData.Count.ShouldEqual(3); folderData.ShouldContain( new[] { new LegacyPlaceholderListDatabase.PlaceholderData("partialFolder", LegacyPlaceholderListDatabase.PartialFolderValue), new LegacyPlaceholderListDatabase.PlaceholderData("expandedFolder", LegacyPlaceholderListDatabase.ExpandedFolderValue), new LegacyPlaceholderListDatabase.PlaceholderData("tombstone", LegacyPlaceholderListDatabase.PossibleTombstoneFolderValue), }, (data1, data2) => data1.Path == data2.Path && data1.Sha == data2.Sha); }
public void WritesPlaceholderAddToFile() { ConfigurableFileSystem fs = new ConfigurableFileSystem(); LegacyPlaceholderListDatabase dut = CreatePlaceholderListDatabase(fs, string.Empty); dut.AddFile(InputGitIgnorePath, InputGitIgnoreSHA); fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(ExpectedGitIgnoreEntry); dut.AddFile(InputGitAttributesPath, InputGitAttributesSHA); fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(ExpectedTwoEntries); }
public void GetAllEntriesReturnsCorrectEntries() { ConfigurableFileSystem fs = new ConfigurableFileSystem(); using (LegacyPlaceholderListDatabase dut1 = CreatePlaceholderListDatabase(fs, string.Empty)) { dut1.AddFile(InputGitIgnorePath, InputGitIgnoreSHA); dut1.AddFile(InputGitAttributesPath, InputGitAttributesSHA); dut1.AddFile(InputThirdFilePath, InputThirdFileSHA); dut1.Remove(InputThirdFilePath); } string error; LegacyPlaceholderListDatabase dut2; LegacyPlaceholderListDatabase.TryCreate(null, MockEntryFileName, fs, out dut2, out error).ShouldEqual(true, error); List <IPlaceholderData> allData = dut2.GetAllEntries(); allData.Count.ShouldEqual(2); }
public void HandlesRaceBetweenAddAndWriteAllEntries() { ConfigurableFileSystem fs = new ConfigurableFileSystem(); fs.ExpectedFiles.Add(MockEntryFileName + ".tmp", new ReusableMemoryStream(string.Empty)); LegacyPlaceholderListDatabase dut = CreatePlaceholderListDatabase(fs, ExpectedGitIgnoreEntry); List <IPlaceholderData> existingEntries = dut.GetAllEntries(); dut.AddFile(InputGitAttributesPath, InputGitAttributesSHA); dut.WriteAllEntriesAndFlush(existingEntries); fs.ExpectedFiles[MockEntryFileName].ReadAsString().ShouldEqual(ExpectedTwoEntries); }