示例#1
0
        public void TestCtor4()
        {
            var settings = new DataSourceSettings
            {
                new DataSource
                {
                    Id = DataSourceId.CreateNew()
                },
                new DataSource
                {
                    Id          = DataSourceId.CreateNew(),
                    DisplayName = "My custom name"
                }
            };

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logSourceFactory, _scheduler, _filesystem, settings, _bookmarks.Object))
            {
                var group1 = dataSources.Sources.First() as IMergedDataSource;
                group1.Should().NotBeNull();
                group1.DisplayName.Should().Be("Merged Data Source", "because merged data sources which don't have a display name shall be assigned a default one");

                var group2 = dataSources.Sources.Last() as IMergedDataSource;
                group2.Should().NotBeNull();
                group2.DisplayName.Should().Be("My custom name", "because a custom name was supplied");
            }
        }
        public DataSourcesViewModel(ApplicationSettings settings, DataSources dataSources)
        {
            if (settings == null) throw new ArgumentNullException("settings");
            if (dataSources == null) throw new ArgumentNullException("dataSources");

            _settings = settings;
            _observable = new ObservableCollection<IDataSourceViewModel>();
            _allDataSourceViewModels = new List<IDataSourceViewModel>();
            _dataSources = dataSources;
            foreach (IDataSource dataSource in dataSources)
            {
                if (dataSource.ParentId == Guid.Empty)
                {
                    Add(dataSource);
                }
            }

            foreach (IDataSource dataSource in dataSources)
            {
                Guid parentId = dataSource.ParentId;
                if (parentId != Guid.Empty)
                {
                    IDataSourceViewModel parent = _observable.First(x => x.DataSource.Id == parentId);
                    var group = (MergedDataSourceViewModel) parent;
                    IDataSourceViewModel viewModel = CreateViewModel(dataSource);
                    group.AddChild(viewModel);
                }
            }
        }
示例#3
0
 public void SetUp()
 {
     _settings       = new Tailviewer.Settings.DataSources();
     _scheduler      = new ManualTaskScheduler();
     _logFileFactory = new PluginLogFileFactory(_scheduler);
     _dataSources    = new DataSources(_logFileFactory, _scheduler, _settings);
     _actionCenter   = new Mock <IActionCenter>();
 }
示例#4
0
 public void TestAddGroup1()
 {
     var settings = new Tailviewer.Settings.DataSources();
     using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_scheduler, settings))
     {
         MergedDataSource group = dataSources.AddGroup();
         group.Should().NotBeNull();
         group.Settings.Should().NotBeNull();
         settings.Should().Equal(group.Settings);
     }
 }
        public void SetUp()
        {
            _settings  = new Tailviewer.Settings.DataSourceSettings();
            _bookmarks = new Mock <IBookmarks>();

            _scheduler      = new ManualTaskScheduler();
            _logFileFactory = new PluginLogFileFactory(_scheduler);
            _filesystem     = new InMemoryFilesystem();
            _dataSources    = new DataSources(_logFileFactory, _scheduler, _filesystem, _settings, _bookmarks.Object);
            _actionCenter   = new Mock <IActionCenter>();
        }
示例#6
0
        public void TestAddGroup1()
        {
            var settings = new Tailviewer.Settings.DataSources();

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logFileFactory, _scheduler, settings))
            {
                MergedDataSource group = dataSources.AddGroup();
                group.Should().NotBeNull();
                group.Settings.Should().NotBeNull();
                settings.Should().Equal(group.Settings);
            }
        }
示例#7
0
        public void TestAddGroup1()
        {
            var settings = new DataSourceSettings();

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logSourceFactory, _scheduler, _filesystem, settings, _bookmarks.Object))
            {
                MergedDataSource group = dataSources.AddGroup();
                group.Should().NotBeNull();
                group.Settings.Should().NotBeNull();
                settings.Should().Equal(group.Settings);
            }
        }
示例#8
0
        public void TestCtor3()
        {
            var settings = new DataSourceSettings
            {
                new DataSource("test1.log")
                {
                    Id = DataSourceId.CreateNew()
                },
                new DataSource("test2.log")
                {
                    Id = DataSourceId.CreateNew()
                },
                new DataSource("test.log")
                {
                    Id = DataSourceId.CreateNew()
                }
            };
            var merged1 = new DataSource {
                Id = DataSourceId.CreateNew()
            };

            settings.Add(merged1);
            var merged2 = new DataSource {
                Id = DataSourceId.CreateNew()
            };

            settings.Add(merged2);
            var merged3 = new DataSource {
                Id = DataSourceId.CreateNew()
            };

            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(_logSourceFactory, _scheduler, _filesystem, settings, _bookmarks.Object))
            {
                dataSources.Count.Should().Be(6, "Because we've loaded 6 data sources");
                var mergedDataSource1 = dataSources[3] as MergedDataSource;
                mergedDataSource1.Should().NotBeNull();
                mergedDataSource1.OriginalSources.Should().Equal(new object[] { dataSources[0] });

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

                var mergedDataSource3 = dataSources[5] as MergedDataSource;
                mergedDataSource3.Should().NotBeNull();
                mergedDataSource3.OriginalSources.Should().Equal(new object[] { dataSources[2] });
            }
        }
示例#9
0
        public void TestCtor5()
        {
            var settings = new DataSourceSettings
            {
                new DataSource
                {
                    Id = DataSourceId.CreateNew(),
                    LogFileFolderPath = @"F:\logs"
                },
            };

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logSourceFactory, _scheduler, _filesystem, settings, _bookmarks.Object))
            {
                var folder = dataSources.Sources.First() as IFolderDataSource;
                folder.Should().NotBeNull();
            }
        }
示例#10
0
 public void TestCtor1()
 {
     var settings = new Tailviewer.Settings.DataSources
         {
             new DataSource(@"E:\Code\test.log")
                 {
                     Id = Guid.NewGuid()
                 }
         };
     using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_scheduler, settings))
     {
         dataSources.Count.Should().Be(1);
         IDataSource dataSource = dataSources.First();
         dataSource.FullFileName.Should().Be(settings[0].File);
         dataSource.Id.Should().Be(settings[0].Id);
     }
 }
示例#11
0
        public void TestCtor1()
        {
            var settings = new DataSourceSettings
            {
                new DataSource(@"E:\Code\test.log")
                {
                    Id = DataSourceId.CreateNew()
                }
            };

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logSourceFactory, _scheduler, _filesystem, settings, _bookmarks.Object))
            {
                dataSources.Count.Should().Be(1);
                IDataSource dataSource = dataSources.Sources.First();
                dataSource.FullFileName.Should().Be(settings[0].File);
                dataSource.Id.Should().Be(settings[0].Id);
            }
        }
示例#12
0
        public void TestCtor2()
        {
            var settings = new DataSourceSettings
            {
                new DataSource("test1.log")
                {
                    Id = DataSourceId.CreateNew()
                },
                new DataSource("test2.log")
                {
                    Id = DataSourceId.CreateNew()
                },
                new DataSource("test.log")
                {
                    Id = DataSourceId.CreateNew()
                }
            };
            var merged = new DataSource {
                Id = DataSourceId.CreateNew()
            };

            settings.Add(merged);
            settings[0].ParentId = merged.Id;
            settings[1].ParentId = merged.Id;

            using (var dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logSourceFactory, _scheduler, _filesystem, settings, _bookmarks.Object))
            {
                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.OriginalSources.Should().Equal(new object[] { dataSource1, dataSource2 });
                dataSource1.ParentId.Should().Be(merged.Id);
                dataSource2.ParentId.Should().Be(merged.Id);
            }
        }
示例#13
0
 public void SetUp()
 {
     _settings    = new DataSourceSettings();
     _bookmarks   = new Mock <IBookmarks>();
     _dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logSourceFactory, _scheduler, _filesystem, _settings, _bookmarks.Object);
 }
示例#14
0
 public void SetUp()
 {
     _settings = new Tailviewer.Settings.DataSources();
     _dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_scheduler, _settings);
 }
示例#15
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]});
            }
        }
示例#16
0
 public void SetUp()
 {
     _settings    = new Tailviewer.Settings.DataSources();
     _dataSources = new Tailviewer.BusinessLogic.DataSources.DataSources(_logFileFactory, _scheduler, _settings);
 }
示例#17
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);
            }
        }