public void TestDeleteFiles() { var files = RandomData.GenerateFiles(100, 10); var errors = FileHelper.DeleteFiles(files.Files); base.Consumer.Consume(errors); }
public void DeleteFilesTest() { (string Path, IEnumerable <string> Files)files = RandomData.GenerateFiles(100, 10); IEnumerable <(string FileName, string ErrorMessage)> errors = FileHelper.DeleteFiles(files.Files); base.Consumer.Consume(errors); }
public override void Setup() { base.Setup(); var result = RandomData.GenerateFiles(count: 1000, fileLength: 1000, FileExtension); _tempFiles = result.Files; _tempFilePath = result.Path; }
private IEnumerable <FileInfo> GenerateTempFiles(int fileCount, int fileLength) { var result = RandomData.GenerateFiles(this._tempFolder.FullName, fileCount, fileLength); var tempFiles = new List <FileInfo>(fileCount); tempFiles.AddRange(result.Select(file => new FileInfo(file))); return(tempFiles); }
public void GenerateFilesWithPathTest() { var files = RandomData.GenerateFiles(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify), Count, FileLength); Assert.IsNotNull(files); Assert.IsTrue(files.FastCount() == Count); this.DeleteFiles(files); }
public void GenerateFilesWithExtTest() { var files = RandomData.GenerateFiles(Count, FileLength, "test"); Assert.IsNotNull(files); Assert.IsNotNull(files.Path); Assert.IsTrue(files.Files.Count() == Count); this.DeleteFiles(files.Files); }
public void TestDeleteFilesWithEvent() { var tempFiles = RandomData.GenerateFiles(_fileCount, _fileLength); var processor = new FileProcessor(); processor.Processed += this.Processor_Processed; _ = processor.DeleteFiles(_tempFiles); processor.Processed -= this.Processor_Processed; }
public void GenerateFilesWithPathTest() { const int length = 500; const int count = 100; var files = RandomData.GenerateFiles(@"c:\temp", count, length); Assert.IsNotNull(files); Assert.IsTrue(files.Count() == count); FileHelper.DeleteFiles(files); }
public void GenerateFilesWithExtTest() { const int length = 500; const int count = 100; var files = RandomData.GenerateFiles(count, length, "test"); Assert.IsNotNull(files); Assert.IsNotNull(files.Path); Assert.IsTrue(files.Files.Count() == count); FileHelper.DeleteFiles(files.Files); }
public void DeleteFilesTest() { try { var filesToDelete = RandomData.GenerateFiles(_tempPath.FullName, 100, 500); var result = FileHelper.DeleteFiles(filesToDelete); Assert.IsTrue(result.Count() == 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void CopyAndMoveDirectoryTest() { var sourcePath = Path.Combine(_tempPath.FullName, $"{nameof(this.CopyAndMoveDirectoryTest)}{RandomData.GenerateKey()}"); var destinationPath = Path.Combine(_tempPath.FullName, nameof(this.CopyAndMoveDirectoryTest)); RandomData.GenerateFiles(sourcePath, 100, 100); var folderToCopy = new DirectoryInfo(sourcePath); try { DirectoryHelper.CopyDirectory(folderToCopy.FullName, _tempPath.FullName, false); DirectoryHelper.MoveDirectory(folderToCopy.FullName, destinationPath, 2); } catch (Exception ex) { Assert.Fail(ex.Message); } finally { DirectoryHelper.DeleteDirectory(destinationPath); } }
public void CopyAndDeleteDirectoryTest() { var destinationPath = Path.Combine(_tempPath.FullName, nameof(this.CopyAndDeleteDirectoryTest)); var sourcePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), $"dotNetTips.com-{DateTime.Now.Ticks}"); _ = RandomData.GenerateFiles(sourcePath, 500, 5000); try { DirectoryHelper.CopyDirectory(sourcePath, destinationPath, false); DirectoryHelper.DeleteDirectory(destinationPath, 3); } catch (Exception ex) { Assert.Fail(ex.Message); } finally { DirectoryHelper.DeleteDirectory(sourcePath, 3); } }