예제 #1
0
 public SingleDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime)
     : base(taskScheduler, settings, maximumWaitTime)
 {
     var logFile = new LogFile(taskScheduler, settings.File);
     _unfilteredLogFile = logFile;
     CreateFilteredLogFile();
 }
예제 #2
0
 public void TestAdd1()
 {
     var settings = new DataSource("foo") {Id = Guid.NewGuid()};
     var dataSource = new SingleDataSource(_scheduler, settings);
     _merged.Add(dataSource);
     settings.ParentId.Should()
             .Be(_settings.Id, "Because the parent-child relationship should've been declared via ParentId");
 }
예제 #3
0
 public void SetUp()
 {
     _settings = new DataSource
         {
             Id = Guid.NewGuid()
         };
     _merged = new MergedDataSource(_scheduler, _settings);
 }
예제 #4
0
 public void TestAdd2()
 {
     var settings = new DataSource("foo") {Id = Guid.NewGuid()};
     var dataSource = new SingleDataSource(_scheduler, settings);
     _merged.Add(dataSource);
     _merged.UnfilteredLogFile.Should().NotBeNull();
     _merged.UnfilteredLogFile.Should().BeOfType<MergedLogFile>();
     ((MergedLogFile) _merged.UnfilteredLogFile).Sources.Should().Equal(new object[] {dataSource.UnfilteredLogFile});
 }
 public void SetUp()
 {
     _quickFilter = new QuickFilter(new Tailviewer.Settings.QuickFilter());
     _dataSource = new SingleDataSource(_scheduler, _dataSourceSettings = new DataSource("nothing") {Id = Guid.NewGuid()});
     _model = new QuickFilterViewModel(_quickFilter, x => { })
         {
             CurrentDataSource = _dataSource
         };
     _changes = new List<string>();
     _model.PropertyChanged += (sender, args) => _changes.Add(args.PropertyName);
 }
예제 #6
0
        public void TestChangeFilter1()
        {
            ILogFile logFile1 = _merged.UnfilteredLogFile;
            _merged.SearchTerm = "foo";
            var settings1 = new DataSource("foo") {Id = Guid.NewGuid()};
            var dataSource1 = new SingleDataSource(_scheduler, settings1);
            _merged.Add(dataSource1);
            ILogFile logFile2 = _merged.UnfilteredLogFile;

            logFile2.Should().NotBeSameAs(logFile1);
            ((AbstractLogFile) logFile1).IsDisposed.Should().BeTrue();
        }
 public void TestCtor1()
 {
     var settings = new DataSource(@"E:\Code\SharpTail\SharpTail.Test\TestData\20Mb.test")
         {
             Id = Guid.NewGuid()
         };
     using (var source = new SingleDataSource(_scheduler, settings))
     {
         var model = new SingleDataSourceViewModel(source);
         model.FullName.Should().Be(@"E:\Code\SharpTail\SharpTail.Test\TestData\20Mb.test");
         model.Id.Should().Be(settings.Id);
     }
 }
        public void SetUp()
        {
            _settings = new DataSource();

            _logFile = new Mock<ILogFile>();

            _dataSource = new Mock<IDataSource>();
            _dataSource.Setup(x => x.UnfilteredLogFile).Returns(_logFile.Object);
            _dataSource.Setup(x => x.Settings).Returns(_settings);
            _dataSource.SetupProperty(x => x.LastViewed);
            _dataSource.Setup(x => x.Search).Returns(new Mock<ILogFileSearch>().Object);
            _dataSource.SetupProperty(x => x.VisibleLogLine);

            _viewModel = new DataSourceViewModel(_dataSource.Object);
        }
예제 #9
0
        protected AbstractDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime)
        {
            if (taskScheduler == null)
                throw new ArgumentNullException("taskScheduler");
            if (settings == null) throw new ArgumentNullException("settings");
            if (settings.Id == Guid.Empty) throw new ArgumentException("settings.Id shall be set to an actually generated id");

            _taskScheduler = taskScheduler;
            _settings = settings;
            _maximumWaitTime = maximumWaitTime;
            _counter = new LogFileCounter();

            _logFile = new LogFileProxy(taskScheduler, maximumWaitTime);
            _search = new LogFileSearchProxy(taskScheduler, _logFile, maximumWaitTime);
            CreateSearch();
        }
예제 #10
0
        public void TestCtor()
        {
            var dataSource = new DataSource();
            dataSource.ColorByLevel.Should().BeTrue();

            dataSource.ActivatedQuickFilters.Should().NotBeNull();
            dataSource.LevelFilter.Should().Be(LevelFlags.All);
            dataSource.File.Should().BeNull();

            dataSource.VisibleLogLine.Should().Be(LogLineIndex.Invalid);
            dataSource.SelectedLogLines.Should().NotBeNull();
            dataSource.SelectedLogLines.Should().BeEmpty();

            dataSource.FollowTail.Should().BeFalse();

            dataSource.ShowLineNumbers.Should().BeTrue();
        }
        public void TestSearch1()
        {
            var settings = new DataSource(LogFileTest.File2Mb) { Id = Guid.NewGuid() };
            using (var logFile = new LogFile(_taskScheduler, LogFileTest.File2Mb))
            using (var dataSource = new SingleDataSource(_taskScheduler, settings, logFile, TimeSpan.Zero))
            {
                var model = new SingleDataSourceViewModel(dataSource);

                logFile.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue();

                model.Update();
                model.TotalCount.Should().Be(16114);

                model.SearchTerm = "RPC #12";
                var search = dataSource.Search;
                search.Property(x => x.Count).ShouldEventually().Be(334);

                model.Update();
                model.SearchResultCount.Should().Be(334);
                model.CurrentSearchResultIndex.Should().Be(0);
            }
        }
예제 #12
0
        public void TestCtor2()
        {
            var settings = new Tailviewer.Settings.DataSources
                {
                    new DataSource("test1.log")
                        {
                            Id = Guid.NewGuid()
                        },
                    new DataSource("test2.log")
                        {
                            Id = Guid.NewGuid()
                        },
                    new DataSource("test.log")
                        {
                            Id = Guid.NewGuid()
                        }
                };
            var merged = new DataSource {Id = Guid.NewGuid()};
            settings.Add(merged);
            settings[0].ParentId = merged.Id;
            settings[1].ParentId = merged.Id;

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_scheduler, settings))
            {
                dataSources.Count.Should().Be(4, "Because we've loaded 4 data sources");
                var mergedDataSource = dataSources[3] as MergedDataSource;
                mergedDataSource.Should().NotBeNull();
                mergedDataSource.DataSourceCount.Should().Be(2, "Because 2 of the data sources are part of this group");
                IDataSource dataSource1 = dataSources[0];
                IDataSource dataSource2 = dataSources[1];

                mergedDataSource.DataSources.Should().Equal(new object[] {dataSource1, dataSource2});
                dataSource1.ParentId.Should().Be(merged.Id);
                dataSource2.ParentId.Should().Be(merged.Id);
            }
        }
예제 #13
0
 public SingleDataSource(ITaskScheduler taskScheduler, DataSource settings)
     : this(taskScheduler, settings, TimeSpan.FromMilliseconds(10))
 {
 }
        public void TestCtor2()
        {
            _settings = new ApplicationSettings("foobar");
            var group = new DataSource {Id = Guid.NewGuid()};
            var source = new DataSource("foo") {Id = Guid.NewGuid(), ParentId = Guid.NewGuid()};
            _settings.DataSources.Add(group);
            _settings.DataSources.Add(source);
            _dataSources = new DataSources(_scheduler, _settings.DataSources);
            new Action(() => _model = new DataSourcesViewModel(_settings, _dataSources)).ShouldNotThrow();
            _model.Observable.Count.Should().Be(2);
            IDataSourceViewModel viewModel = _model.Observable[0];
            viewModel.Should().NotBeNull();
            viewModel.Should().BeOfType<MergedDataSourceViewModel>();
            viewModel.DataSource.Id.Should().Be(group.Id);
            var merged = (MergedDataSourceViewModel) viewModel;
            merged.Observable.Should().BeEmpty();

            viewModel = _model.Observable[1];
            viewModel.Should().NotBeNull();
            viewModel.Should().BeOfType<SingleDataSourceViewModel>();
        }
        public void TestCtor1()
        {
            _settings = new ApplicationSettings("foobar");
            var group = new DataSource {Id = Guid.NewGuid()};
            var source1 = new DataSource("foo") {Id = Guid.NewGuid(), ParentId = group.Id};
            var source2 = new DataSource("bar") {Id = Guid.NewGuid(), ParentId = group.Id};
            var source3 = new DataSource("clondyke") {Id = Guid.NewGuid()};
            _settings.DataSources.Add(group);
            _settings.DataSources.Add(source1);
            _settings.DataSources.Add(source2);
            _settings.DataSources.Add(source3);
            _dataSources = new DataSources(_scheduler, _settings.DataSources);
            _model = new DataSourcesViewModel(_settings, _dataSources);
            _model.Observable.Count.Should().Be(2);
            IDataSourceViewModel viewModel = _model.Observable[0];
            viewModel.Should().NotBeNull();
            viewModel.Should().BeOfType<MergedDataSourceViewModel>();
            viewModel.DataSource.Id.Should().Be(group.Id);
            var merged = (MergedDataSourceViewModel) viewModel;
            merged.Observable.Count().Should().Be(2);
            merged.Observable.ElementAt(0).DataSource.Id.Should().Be(source1.Id);
            merged.Observable.ElementAt(1).DataSource.Id.Should().Be(source2.Id);

            viewModel = _model.Observable[1];
            viewModel.Should().NotBeNull();
            viewModel.Should().BeOfType<SingleDataSourceViewModel>();
            viewModel.DataSource.Id.Should().Be(source3.Id);
        }
        public void TestRemove2()
        {
            _settings = new ApplicationSettings("foobar");
            var group = new DataSource {Id = Guid.NewGuid()};
            var source1 = new DataSource("foo") {Id = Guid.NewGuid(), ParentId = group.Id};
            var source2 = new DataSource("bar") {Id = Guid.NewGuid(), ParentId = group.Id};
            var source3 = new DataSource("clondyke") {Id = Guid.NewGuid(), ParentId = group.Id};
            _settings.DataSources.Add(source1);
            _settings.DataSources.Add(source2);
            _settings.DataSources.Add(source3);
            _settings.DataSources.Add(group);
            _dataSources = new DataSources(_scheduler, _settings.DataSources);
            _model = new DataSourcesViewModel(_settings, _dataSources);
            var merged = (MergedDataSourceViewModel) _model.Observable[0];
            IDataSourceViewModel viewModel1 = merged.Observable.ElementAt(0);
            IDataSourceViewModel viewModel2 = merged.Observable.ElementAt(1);
            IDataSourceViewModel viewModel3 = merged.Observable.ElementAt(2);
            viewModel1.RemoveCommand.Execute(null);

            merged.ChildCount.Should().Be(2);
            merged.Observable.Should().NotContain(viewModel1);
            _model.Observable.Should().Equal(new object[] {merged});
            _dataSources.Should().Equal(new object[] {viewModel2.DataSource, viewModel3.DataSource, merged.DataSource});
            _settings.DataSources.Should().Equal(new object[] {source2, source3, group});
        }
        public void TestRemove1()
        {
            _settings = new ApplicationSettings("foobar");
            var source = new DataSource("foo") {Id = Guid.NewGuid()};
            _settings.DataSources.Add(source);
            _dataSources = new DataSources(_scheduler, _settings.DataSources);
            _model = new DataSourcesViewModel(_settings, _dataSources);
            IDataSourceViewModel viewModel = _model.Observable[0];
            viewModel.RemoveCommand.Execute(null);

            _model.Observable.Should().BeEmpty();
            _dataSources.Should().BeEmpty();
            _settings.DataSources.Should().BeEmpty();
        }
예제 #18
0
        public void TestRemove2()
        {
            var settings1 = new DataSource("foo") {Id = Guid.NewGuid()};
            var dataSource1 = new SingleDataSource(_scheduler, settings1);
            _merged.Add(dataSource1);

            var settings2 = new DataSource("bar") {Id = Guid.NewGuid()};
            var dataSource2 = new SingleDataSource(_scheduler, settings2);
            _merged.Add(dataSource2);

            _merged.Remove(dataSource2);
            _merged.UnfilteredLogFile.Should().NotBeNull();
            _merged.UnfilteredLogFile.Should().BeOfType<MergedLogFile>();
            ((MergedLogFile) _merged.UnfilteredLogFile).Sources.Should().Equal(new object[] {dataSource1.UnfilteredLogFile});
        }
예제 #19
0
 public void TestRemove1()
 {
     var settings = new DataSource("foo") {Id = Guid.NewGuid()};
     var dataSource = new SingleDataSource(_scheduler, settings);
     _merged.Add(dataSource);
     _merged.Remove(dataSource);
     dataSource.Settings.ParentId.Should().Be(Guid.Empty);
 }
예제 #20
0
 public SingleDataSource(ITaskScheduler taskScheduler, DataSource settings, ILogFile unfilteredLogFile, TimeSpan maximumWaitTime)
     : base(taskScheduler, settings, maximumWaitTime)
 {
     _unfilteredLogFile = unfilteredLogFile;
     CreateFilteredLogFile();
 }
 public void TestSetQuickFilterChain1()
 {
     var settings = new DataSource(@"E:\Code\SharpTail\SharpTail.Test\TestData\20Mb.test")
         {
             Id = Guid.NewGuid()
         };
     using (var dataSource = new SingleDataSource(_scheduler, settings))
     {
         var model = new SingleDataSourceViewModel(dataSource);
         var chain = new[] {new SubstringFilter("foobar", true)};
         model.QuickFilterChain = chain;
         model.QuickFilterChain.Should().BeSameAs(chain);
         dataSource.QuickFilterChain.Should().BeSameAs(chain);
     }
 }
예제 #22
0
        public void TestCtor3()
        {
            var settings = new Tailviewer.Settings.DataSources
                {
                    new DataSource("test1.log")
                        {
                            Id = Guid.NewGuid()
                        },
                    new DataSource("test2.log")
                        {
                            Id = Guid.NewGuid()
                        },
                    new DataSource("test.log")
                        {
                            Id = Guid.NewGuid()
                        }
                };
            var merged1 = new DataSource {Id = Guid.NewGuid()};
            settings.Add(merged1);
            var merged2 = new DataSource {Id = Guid.NewGuid()};
            settings.Add(merged2);
            var merged3 = new DataSource {Id = Guid.NewGuid()};
            settings.Add(merged3);
            settings[0].ParentId = merged1.Id;
            settings[1].ParentId = merged2.Id;
            settings[2].ParentId = merged3.Id;

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_scheduler, settings))
            {
                dataSources.Count.Should().Be(6, "Because we've loaded 6 data sources");
                var mergedDataSource1 = dataSources[3] as MergedDataSource;
                mergedDataSource1.Should().NotBeNull();
                mergedDataSource1.DataSources.Should().Equal(new object[] {dataSources[0]});

                var mergedDataSource2 = dataSources[4] as MergedDataSource;
                mergedDataSource2.Should().NotBeNull();
                mergedDataSource2.DataSources.Should().Equal(new object[] {dataSources[1]});

                var mergedDataSource3 = dataSources[5] as MergedDataSource;
                mergedDataSource3.Should().NotBeNull();
                mergedDataSource3.DataSources.Should().Equal(new object[] {dataSources[2]});
            }
        }