public void TestNoSuchDrive() { var dataSource = new FolderDataSource(_taskScheduler, _logFileFactory, _filesystem, _settings, TimeSpan.Zero); var path = Path.Combine("Z:\\", "logs"); dataSource.Change(path, "*", false); dataSource.OriginalSources.Should().BeEmpty(); }
public void TestNoSuchFolder() { var dataSource = new FolderDataSource(_taskScheduler, _logFileFactory, _filesystem, _settings, TimeSpan.Zero); var path = Path.Combine(_filesystem.Roots.First().FullName, "logs"); dataSource.Change(path, "*", false); _taskScheduler.RunOnce(); dataSource.OriginalSources.Should().BeEmpty(); }
public void TestChange([Values(null, "", @"C:\temp")] string folderPath, [Values(null, "", "*.log")] string logFileRegex, [Values(true, false)] bool recursive) { var dataSource = new FolderDataSource(_taskScheduler, _logFileFactory, _filesystem, _settings, TimeSpan.Zero); dataSource.Change(folderPath, logFileRegex, recursive); dataSource.LogFileFolderPath.Should().Be(folderPath); dataSource.LogFileSearchPattern.Should().Be(logFileRegex); dataSource.Recursive.Should().Be(recursive); _settings.LogFileFolderPath.Should().Be(folderPath); _settings.LogFileSearchPattern.Should().Be(logFileRegex); _settings.Recursive.Should().Be(recursive); }
public void TestMultiplePatterns() { var dataSource = new FolderDataSource(_taskScheduler, _logFileFactory, _filesystem, _settings, TimeSpan.Zero); var path = Path.Combine(_filesystem.Roots.First().FullName, "logs"); _filesystem.CreateDirectory(path); _filesystem.WriteAllBytes(Path.Combine(path, "foo.log"), new byte[0]); _filesystem.WriteAllBytes(Path.Combine(path, "foo.bar"), new byte[0]); _filesystem.WriteAllBytes(Path.Combine(path, "foo.txt"), new byte[0]); dataSource.Change(path, "*.log;*.txt", false); _taskScheduler.RunOnce(); dataSource.Property(x => (IEnumerable <IDataSource>)x.OriginalSources).ShouldEventually().HaveCount(2); dataSource.OriginalSources[0].FullFileName.Should().Be(Path.Combine(path, "foo.log")); dataSource.OriginalSources[1].FullFileName.Should().Be(Path.Combine(path, "foo.txt")); }
public void TestTooManySources() { var dataSource = new FolderDataSource(_taskScheduler, _logFileFactory, _filesystem, _settings, TimeSpan.Zero); var path = Path.Combine(_filesystem.Roots.First().FullName, "logs"); _filesystem.CreateDirectory(path); for (int i = 0; i < 257; ++i) { _filesystem.WriteAllBytes(Path.Combine(path, $"{i}.txt"), new byte[0]); } dataSource.Change(path, "*.log;*.txt", false); _taskScheduler.RunOnce(); dataSource.Property(x => (IEnumerable <IDataSource>)x.OriginalSources).ShouldEventually().HaveCount(255, "because merged log file cannot merge more than 256 logs"); dataSource.UnfilteredFileCount.Should().Be(257); dataSource.FilteredFileCount.Should().Be(257); }