Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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);
        }