public void Search_RootPath_ExcludeFileFromSaving() { // arrange var expectedItemsForSave = EnvironmentBuilder.Create(_numberOfDirectories, _numberOfFiles); var listener = new Listener(_fileSystemVisitor, expectedItemsForSave, _countItemsForExclude); //act _fileSystemVisitor.Search(_rootPath); EnvironmentBuilder.Clear(_rootPath); //assert Assert.AreEqual(_countItemsForExclude, _fileSystemVisitor.Count); }
public void Search_RootPath_CancelAfterSaveFirstItem() { // arrange var expectedItemsForSave = EnvironmentBuilder.Create(_numberOfDirectories, _numberOfFiles); var listener = new Listener(_fileSystemVisitor, _countItemsForCancel, expectedItemsForSave); //act _fileSystemVisitor.Search(_rootPath); EnvironmentBuilder.Clear(_rootPath); //assert Assert.AreEqual(_countItemsForCancel, _fileSystemVisitor.Count); }
public void Search_RootPath_AllFilesAndDirectoriesFoundAndSave() { // arrange var expectedItemsForSave = EnvironmentBuilder.Create(_numberOfDirectories, _numberOfFiles); var listener = new Listener(_fileSystemVisitor, expectedItemsForSave, expectedItemsForSave); //act _fileSystemVisitor.Search(_rootPath); EnvironmentBuilder.Clear(_rootPath); //assert Assert.AreEqual(expectedItemsForSave, _fileSystemVisitor.Count); }
static void Main(string[] args) { if (!int.TryParse(ConfigurationManager.AppSettings["numberOfDirectories"], out var numberOfDirectories)) { throw new ArgumentException($"Incorrect setting value {ConfigurationManager.AppSettings["numberOfDirectories"]}"); } if (!int.TryParse(ConfigurationManager.AppSettings["numberOfFiles"], out var numberOfFiles)) { throw new ArgumentException($"Incorrect setting value {ConfigurationManager.AppSettings["numberOfFiles"]}"); } var visitor = new FileSystemVisitor( new Validator(x => x.Contains("Debug")), new SaveManager()); var rootPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["nameDirectory"]); var expectedItemsForSave = EnvironmentBuilder.Create(numberOfDirectories, numberOfFiles); var listener = new Listener(visitor, expectedItemsForSave + 1, expectedItemsForSave + 1); visitor.Search(rootPath); Directory.Delete(rootPath, true); }
/// <summary> /// Generates the collection /// </summary> public void Generate() => _exporter.Export(_builder.Create(), GenerateFileName());