public void TestRoundtripOneQuickFilter() { var id = QuickFilterId.CreateNew(); var config = new LogEntryCountAnalyserConfiguration { QuickFilters = { new QuickFilter { Id = id, IgnoreCase = true, IsInverted = false, MatchType = FilterMatchType.WildcardFilter, Value = "dawawdawdaw" } } }; var actualConfig = Roundtrip(config); actualConfig.Should().NotBeNull(); actualConfig.QuickFilters.Should().NotBeNull(); actualConfig.QuickFilters.Should().HaveCount(1); var quickFilter = actualConfig.QuickFilters.First(); quickFilter.Id.Should().Be(id); quickFilter.IgnoreCase.Should().BeTrue(); quickFilter.IsInverted.Should().BeFalse(); quickFilter.MatchType.Should().Be(FilterMatchType.WildcardFilter); quickFilter.Value.Should().Be("dawawdawdaw"); }
public void TestRoundtrip([Values(true, false)] bool ignoreCase, [Values(true, false)] bool isInverted, [Values(FilterMatchType.RegexpFilter, FilterMatchType.SubstringFilter, FilterMatchType.WildcardFilter)] FilterMatchType matchType, [Values("", "foo", "bar")] string value) { var id = QuickFilterId.CreateNew(); var config = new QuickFilter { Id = id, IgnoreCase = ignoreCase, IsInverted = isInverted, MatchType = matchType, Value = value }; var actualQuickFilter = Roundtrip(config); actualQuickFilter.Should().NotBeNull(); actualQuickFilter.Id.Should().Be(id); actualQuickFilter.IgnoreCase.Should().Be(ignoreCase); actualQuickFilter.IsInverted.Should().Be(isInverted); actualQuickFilter.MatchType.Should().Be(matchType); actualQuickFilter.Value.Should().Be(value); }
/// <summary> /// Initializes this quick filter. /// </summary> public QuickFilter() { Id = QuickFilterId.CreateNew(); IgnoreCase = true; IsInverted = false; }
public void TestStoreRestore() { const string fileName = "applicationsettingstest.xml"; var settings = new ApplicationSettings(fileName); settings.MainWindow.Left = 1; settings.MainWindow.Top = 2; settings.MainWindow.Width = 3; settings.MainWindow.Height = 4; settings.MainWindow.State = WindowState.Maximized; settings.DataSources.Add(new DataSource(@"SharpRemote.Host.1600.log") { Id = DataSourceId.CreateNew(), FollowTail = true, SearchTerm = "foobar", LevelFilter = LevelFlags.Debug, VisibleLogLine = new LogLineIndex(1), ShowLineNumbers = false, HideEmptyLines = true, ActivatedQuickFilters = { QuickFilterId.CreateNew(), QuickFilterId.CreateNew(), QuickFilterId.CreateNew(), } }); settings.DataSources.Add(new DataSource(@"SharpRemote.Host.1700.log") { Id = DataSourceId.CreateNew(), FollowTail = false, ShowLineNumbers = true, IsSingleLine = true, }); List <QuickFilterId> guids = settings.DataSources[0].ActivatedQuickFilters.ToList(); settings.QuickFilters.Add(new QuickFilter { Value = "foobar", IgnoreCase = true, MatchType = FilterMatchType.RegexpFilter, IsInverted = true, }); settings.QuickFilters.Add(new QuickFilter { Value = "clondykebar", IgnoreCase = false, MatchType = FilterMatchType.WildcardFilter, IsInverted = false, }); QuickFilterId filterId1 = settings.QuickFilters[0].Id; QuickFilterId filterId2 = settings.QuickFilters[1].Id; settings.DataSources.SelectedItem = settings.DataSources[0].Id; settings.Export.ExportFolder = @"C:\hello\world"; settings.LogFile.DefaultEncoding = Encoding.BigEndianUnicode; settings.Save().Should().BeTrue(); settings = new ApplicationSettings(fileName); settings.Restore(); settings.MainWindow.Left.Should().Be(1); settings.MainWindow.Top.Should().Be(2); settings.MainWindow.Width.Should().Be(3); settings.MainWindow.Height.Should().Be(4); settings.MainWindow.State.Should().Be(WindowState.Maximized); settings.DataSources.Count.Should().Be(2); settings.DataSources[0].File.Should().Be(@"SharpRemote.Host.1600.log"); settings.DataSources[0].FollowTail.Should().BeTrue(); settings.DataSources[0].ShowLineNumbers.Should().BeFalse(); settings.DataSources[0].HideEmptyLines.Should().BeTrue(); settings.DataSources[0].IsSingleLine.Should().BeFalse(); settings.DataSources[0].SearchTerm.Should().Be("foobar"); settings.DataSources[0].LevelFilter.Should().Be(LevelFlags.Debug); settings.DataSources[0].VisibleLogLine.Should().Be(new LogLineIndex(1)); settings.DataSources[0].ActivatedQuickFilters.Should().Equal(guids); settings.DataSources[1].File.Should().Be(@"SharpRemote.Host.1700.log"); settings.DataSources[1].FollowTail.Should().BeFalse(); settings.DataSources[1].ShowLineNumbers.Should().BeTrue(); settings.DataSources[1].HideEmptyLines.Should().BeFalse(); settings.DataSources[1].IsSingleLine.Should().BeTrue(); settings.DataSources.SelectedItem.Should().NotBe(Guid.Empty); settings.DataSources.SelectedItem.Should().Be(settings.DataSources[0].Id); settings.QuickFilters.Count.Should().Be(2); settings.QuickFilters[0].Id.Should().Be(filterId1); settings.QuickFilters[0].Value.Should().Be("foobar"); settings.QuickFilters[0].IgnoreCase.Should().BeTrue(); settings.QuickFilters[0].MatchType.Should().Be(FilterMatchType.RegexpFilter); settings.QuickFilters[0].IsInverted.Should().BeTrue(); settings.QuickFilters[1].Id.Should().Be(filterId2); settings.QuickFilters[1].Value.Should().Be("clondykebar"); settings.QuickFilters[1].IgnoreCase.Should().BeFalse(); settings.QuickFilters[1].MatchType.Should().Be(FilterMatchType.WildcardFilter); settings.QuickFilters[1].IsInverted.Should().BeFalse(); settings.Export.Should().NotBeNull(); settings.Export.ExportFolder.Should().Be(@"C:\hello\world"); settings.LogFile.DefaultEncoding.Should().Be(Encoding.BigEndianUnicode); }
public void TestClone([ValueSource(nameof(Bool))] bool hideEmptyLines, [ValueSource(nameof(Bool))] bool showLineNumbers, [ValueSource(nameof(Bool))] bool showDeltaTimes, [ValueSource(nameof(Bool))] bool showElapsedTime, [ValueSource(nameof(Bool))] bool colorByLevel, [ValueSource(nameof(Bool))] bool followTail, [ValueSource(nameof(Bool))] bool isSingleLine, [ValueSource(nameof(Bool))] bool isExpanded, [ValueSource(nameof(DisplayModes))] DataSourceDisplayMode displayMode) { var id = DataSourceId.CreateNew(); var parent = DataSourceId.CreateNew(); var filter = QuickFilterId.CreateNew(); var dataSource = new DataSource { VisibleLogLine = new LogLineIndex(42), LastViewed = new DateTime(2017, 5, 1, 17, 4, 0), Order = 10, HideEmptyLines = hideEmptyLines, File = @"F:\foo.db", Id = id, ShowLineNumbers = showLineNumbers, ShowDeltaTimes = showDeltaTimes, ShowElapsedTime = showElapsedTime, HorizontalOffset = 101, ColorByLevel = colorByLevel, FollowTail = followTail, IsSingleLine = isSingleLine, IsExpanded = isExpanded, LevelFilter = LevelFlags.Fatal, ParentId = parent, SearchTerm = "stuff", SelectedLogLines = { new LogLineIndex(1), new LogLineIndex(10) }, ActivatedQuickFilters = { filter }, MergedDataSourceDisplayMode = displayMode, DisplayName = "Some fancy name" }; var cloned = ((ICloneable)dataSource).Clone() as DataSource; cloned.Should().NotBeNull(); cloned.Should().NotBeSameAs(dataSource); cloned.VisibleLogLine.Should().Be(new LogLineIndex(42)); cloned.LastViewed.Should().Be(new DateTime(2017, 5, 1, 17, 4, 0)); cloned.Order.Should().Be(10); cloned.HideEmptyLines.Should().Be(hideEmptyLines); cloned.File.Should().Be(@"F:\foo.db"); cloned.Id.Should().Be(id); cloned.ShowLineNumbers.Should().Be(showLineNumbers); cloned.ShowDeltaTimes.Should().Be(showDeltaTimes); cloned.ShowElapsedTime.Should().Be(showElapsedTime); cloned.HorizontalOffset.Should().Be(101); cloned.ColorByLevel.Should().Be(colorByLevel); cloned.FollowTail.Should().Be(followTail); cloned.IsSingleLine.Should().Be(isSingleLine); cloned.IsExpanded.Should().Be(isExpanded); cloned.LevelFilter.Should().Be(LevelFlags.Fatal); cloned.ParentId.Should().Be(parent); cloned.SearchTerm.Should().Be("stuff"); cloned.SelectedLogLines.Should().BeEquivalentTo(new LogLineIndex(1), new LogLineIndex(10)); cloned.SelectedLogLines.Should().NotBeSameAs(dataSource.SelectedLogLines); cloned.ActivatedQuickFilters.Should().Equal(new object[] { filter }); cloned.ActivatedQuickFilters.Should().NotBeSameAs(dataSource.ActivatedQuickFilters); cloned.MergedDataSourceDisplayMode.Should().Be(displayMode); cloned.DisplayName.Should().Be("Some fancy name"); }
public void TestSaveRestore([ValueSource(nameof(Bool))] bool hideEmptyLines, [ValueSource(nameof(Bool))] bool showLineNumbers, [ValueSource(nameof(Bool))] bool showDeltaTimes, [ValueSource(nameof(Bool))] bool showElapsedTime, [ValueSource(nameof(Bool))] bool colorByLevel, [ValueSource(nameof(Bool))] bool followTail, [ValueSource(nameof(Bool))] bool isSingleLine, [ValueSource(nameof(Bool))] bool isExpanded, [ValueSource(nameof(DisplayModes))] DataSourceDisplayMode displayMode) { var id = DataSourceId.CreateNew(); var parent = DataSourceId.CreateNew(); var filter = QuickFilterId.CreateNew(); using (var stream = new MemoryStream()) { using (var writer = XmlWriter.Create(stream)) { writer.WriteStartElement("Test"); var dataSource = new DataSource { VisibleLogLine = new LogLineIndex(42), LastViewed = new DateTime(2017, 5, 1, 17, 4, 0), //Order = 10, HideEmptyLines = hideEmptyLines, File = @"F:\foo.db", Id = id, ShowLineNumbers = showLineNumbers, ShowDeltaTimes = showDeltaTimes, ShowElapsedTime = showElapsedTime, HorizontalOffset = 101, ColorByLevel = colorByLevel, FollowTail = followTail, IsSingleLine = isSingleLine, IsExpanded = isExpanded, LevelFilter = LevelFlags.Fatal, ParentId = parent, SearchTerm = "stuff", //SelectedLogLines = //{ // new LogLineIndex(1), // new LogLineIndex(10) //}, ActivatedQuickFilters = { filter }, MergedDataSourceDisplayMode = displayMode, DisplayName = "A stupid name" }; dataSource.Save(writer); } stream.Position = 0; //Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray())); using (var reader = XmlReader.Create(stream)) { reader.MoveToContent(); var dataSource = new DataSource(); bool unused; dataSource.Restore(reader, out unused); dataSource.VisibleLogLine.Should().Be(new LogLineIndex(42)); dataSource.LastViewed.Should().Be(new DateTime(2017, 5, 1, 17, 4, 0)); //dataSource.Order.Should().Be(10); dataSource.HideEmptyLines.Should().Be(hideEmptyLines); dataSource.File.Should().Be(@"F:\foo.db"); dataSource.Id.Should().Be(id); dataSource.ShowLineNumbers.Should().Be(showLineNumbers); dataSource.ShowDeltaTimes.Should().Be(showDeltaTimes); dataSource.ShowElapsedTime.Should().Be(showElapsedTime); dataSource.HorizontalOffset.Should().Be(101); dataSource.ColorByLevel.Should().Be(colorByLevel); dataSource.FollowTail.Should().Be(followTail); dataSource.IsSingleLine.Should().Be(isSingleLine); dataSource.IsExpanded.Should().Be(isExpanded); dataSource.LevelFilter.Should().Be(LevelFlags.Fatal); dataSource.ParentId.Should().Be(parent); dataSource.SearchTerm.Should().Be("stuff"); //dataSource.SelectedLogLines.Should().BeEquivalentTo(new LogLineIndex(1), new LogLineIndex(10)); dataSource.ActivatedQuickFilters.Should().Equal(new object[] { filter }); dataSource.MergedDataSourceDisplayMode.Should().Be(displayMode); dataSource.DisplayName.Should().Be("A stupid name"); } } }
public void TestClone1([ValueSource(nameof(Bool))] bool hideEmptyLines, [ValueSource(nameof(Bool))] bool showLineNumbers, [ValueSource(nameof(Bool))] bool showDeltaTimes, [ValueSource(nameof(Bool))] bool showElapsedTime, [ValueSource(nameof(Bool))] bool colorByLevel) { var id = DataSourceId.CreateNew(); var parent = DataSourceId.CreateNew(); var filter = QuickFilterId.CreateNew(); var dataSource = new DataSource { VisibleLogLine = new LogLineIndex(42), LastViewed = new DateTime(2017, 5, 1, 17, 4, 0), Order = 10, HideEmptyLines = hideEmptyLines, File = @"F:\foo.db", Id = id, ShowLineNumbers = showLineNumbers, ShowDeltaTimes = showDeltaTimes, ShowElapsedTime = showElapsedTime, HorizontalOffset = 101, ColorByLevel = colorByLevel, LevelFilter = LevelFlags.Fatal, ParentId = parent, LogFileFolderPath = @"C:\temp\logs", LogFileSearchPattern = "*.log", SearchTerm = "stuff", SelectedLogLines = { new LogLineIndex(1), new LogLineIndex(10) }, ActivatedQuickFilters = { filter }, DisplayName = "Some fancy name" }; var cloned = ((ICloneable)dataSource).Clone() as DataSource; cloned.Should().NotBeNull(); cloned.Should().NotBeSameAs(dataSource); cloned.VisibleLogLine.Should().Be(new LogLineIndex(42)); cloned.LastViewed.Should().Be(new DateTime(2017, 5, 1, 17, 4, 0)); cloned.Order.Should().Be(10); cloned.HideEmptyLines.Should().Be(hideEmptyLines); cloned.File.Should().Be(@"F:\foo.db"); cloned.Id.Should().Be(id); cloned.ShowLineNumbers.Should().Be(showLineNumbers); cloned.ShowDeltaTimes.Should().Be(showDeltaTimes); cloned.ShowElapsedTime.Should().Be(showElapsedTime); cloned.HorizontalOffset.Should().Be(101); cloned.ColorByLevel.Should().Be(colorByLevel); cloned.LevelFilter.Should().Be(LevelFlags.Fatal); cloned.ParentId.Should().Be(parent); cloned.LogFileFolderPath.Should().Be(@"C:\temp\logs"); cloned.LogFileSearchPattern.Should().Be("*.log"); cloned.SearchTerm.Should().Be("stuff"); cloned.SelectedLogLines.Should().BeEquivalentTo(new LogLineIndex(1), new LogLineIndex(10)); cloned.SelectedLogLines.Should().NotBeSameAs(dataSource.SelectedLogLines); cloned.ActivatedQuickFilters.Should().Equal(new object[] { filter }); cloned.ActivatedQuickFilters.Should().NotBeSameAs(dataSource.ActivatedQuickFilters); cloned.DisplayName.Should().Be("Some fancy name"); }
public void TestSaveRestore2([ValueSource(nameof(Bool))] bool followTail, [ValueSource(nameof(Bool))] bool isSingleLine, [ValueSource(nameof(Bool))] bool isExpanded, [ValueSource(nameof(Bool))] bool recursive, [ValueSource(nameof(DisplayModes))] DataSourceDisplayMode displayMode) { var id = DataSourceId.CreateNew(); var parent = DataSourceId.CreateNew(); var filter = QuickFilterId.CreateNew(); var excluded = new HashSet <DataSourceId> { DataSourceId.CreateNew(), DataSourceId.CreateNew() }; using (var stream = new MemoryStream()) { using (var writer = XmlWriter.Create(stream)) { writer.WriteStartElement("Test"); var dataSource = new DataSource { VisibleLogLine = new LogLineIndex(42), LastViewed = new DateTime(2017, 5, 1, 17, 4, 0), //Order = 10, File = @"F:\foo.db", Id = id, HorizontalOffset = 101, FollowTail = followTail, IsSingleLine = isSingleLine, IsExpanded = isExpanded, LevelFilter = LevelFlags.Fatal, ParentId = parent, LogFileFolderPath = @"E:\logs\", LogFileSearchPattern = "*.txt", Recursive = recursive, SearchTerm = "stuff", //SelectedLogLines = //{ // new LogLineIndex(1), // new LogLineIndex(10) //}, ActivatedQuickFilters = { filter }, MergedDataSourceDisplayMode = displayMode, DisplayName = "A stupid name", ExcludedDataSources = excluded }; dataSource.Save(writer); } stream.Position = 0; //Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray())); using (var reader = XmlReader.Create(stream)) { reader.MoveToContent(); var dataSource = new DataSource(); bool unused; dataSource.Restore(reader, out unused); dataSource.VisibleLogLine.Should().Be(new LogLineIndex(42)); dataSource.LastViewed.Should().Be(new DateTime(2017, 5, 1, 17, 4, 0)); //dataSource.Order.Should().Be(10); dataSource.File.Should().Be(@"F:\foo.db"); dataSource.Id.Should().Be(id); dataSource.HorizontalOffset.Should().Be(101); dataSource.FollowTail.Should().Be(followTail); dataSource.IsSingleLine.Should().Be(isSingleLine); dataSource.IsExpanded.Should().Be(isExpanded); dataSource.LevelFilter.Should().Be(LevelFlags.Fatal); dataSource.ParentId.Should().Be(parent); dataSource.LogFileFolderPath.Should().Be(@"E:\logs\"); dataSource.LogFileSearchPattern.Should().Be("*.txt"); dataSource.Recursive.Should().Be(recursive); dataSource.SearchTerm.Should().Be("stuff"); //dataSource.SelectedLogLines.Should().BeEquivalentTo(new LogLineIndex(1), new LogLineIndex(10)); dataSource.ActivatedQuickFilters.Should().Equal(new object[] { filter }); dataSource.MergedDataSourceDisplayMode.Should().Be(displayMode); dataSource.DisplayName.Should().Be("A stupid name"); dataSource.ExcludedDataSources.Should().BeEquivalentTo(excluded); } } }
public void TestClone2([ValueSource(nameof(Bool))] bool followTail, [ValueSource(nameof(Bool))] bool isSingleLine, [ValueSource(nameof(Bool))] bool isExpanded, [ValueSource(nameof(Bool))] bool recursive, [ValueSource(nameof(DisplayModes))] DataSourceDisplayMode displayMode) { var id = DataSourceId.CreateNew(); var parent = DataSourceId.CreateNew(); var filter = QuickFilterId.CreateNew(); var dataSource = new DataSource { VisibleLogLine = new LogLineIndex(42), LastViewed = new DateTime(2017, 5, 1, 17, 4, 0), Order = 10, File = @"F:\foo.db", Id = id, HorizontalOffset = 101, FollowTail = followTail, IsSingleLine = isSingleLine, IsExpanded = isExpanded, LevelFilter = LevelFlags.Fatal, ParentId = parent, LogFileFolderPath = @"C:\temp\logs", LogFileSearchPattern = "*.log", Recursive = recursive, SearchTerm = "stuff", SelectedLogLines = { new LogLineIndex(1), new LogLineIndex(10) }, ActivatedQuickFilters = { filter }, MergedDataSourceDisplayMode = displayMode, DisplayName = "Some fancy name", ExcludedDataSources = new HashSet <DataSourceId> { DataSourceId.CreateNew(), DataSourceId.CreateNew() } }; var cloned = ((ICloneable)dataSource).Clone() as DataSource; cloned.Should().NotBeNull(); cloned.Should().NotBeSameAs(dataSource); cloned.VisibleLogLine.Should().Be(new LogLineIndex(42)); cloned.LastViewed.Should().Be(new DateTime(2017, 5, 1, 17, 4, 0)); cloned.Order.Should().Be(10); cloned.File.Should().Be(@"F:\foo.db"); cloned.Id.Should().Be(id); cloned.HorizontalOffset.Should().Be(101); cloned.FollowTail.Should().Be(followTail); cloned.IsSingleLine.Should().Be(isSingleLine); cloned.IsExpanded.Should().Be(isExpanded); cloned.LevelFilter.Should().Be(LevelFlags.Fatal); cloned.ParentId.Should().Be(parent); cloned.LogFileFolderPath.Should().Be(@"C:\temp\logs"); cloned.LogFileSearchPattern.Should().Be("*.log"); cloned.Recursive.Should().Be(recursive); cloned.SearchTerm.Should().Be("stuff"); cloned.SelectedLogLines.Should().BeEquivalentTo(new LogLineIndex(1), new LogLineIndex(10)); cloned.SelectedLogLines.Should().NotBeSameAs(dataSource.SelectedLogLines); cloned.ActivatedQuickFilters.Should().Equal(new object[] { filter }); cloned.ActivatedQuickFilters.Should().NotBeSameAs(dataSource.ActivatedQuickFilters); cloned.MergedDataSourceDisplayMode.Should().Be(displayMode); cloned.DisplayName.Should().Be("Some fancy name"); cloned.ExcludedDataSources.Should().NotBeSameAs(dataSource.ExcludedDataSources); cloned.ExcludedDataSources.Should().BeEquivalentTo(dataSource.ExcludedDataSources); }