public void TestStoreRestore()
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = XmlWriter.Create(stream))
                {
                    writer.WriteStartElement("Test");
                    var settings = new QuickFilters
                    {
                        TimeFilter = { SpecialInterval = SpecialDateTimeInterval.ThisWeek }
                    };
                    settings.Add(new QuickFilter {
                        Value = "42"
                    });
                    settings.Save(writer);
                    writer.WriteEndElement();
                }

                stream.Position = 0;
                //Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));

                using (var reader = XmlReader.Create(stream))
                {
                    reader.MoveToContent();

                    var settings = new QuickFilters();
                    settings.Restore(reader);
                    settings.TimeFilter.SpecialInterval.Should().Be(SpecialDateTimeInterval.ThisWeek);
                    settings.Should().HaveCount(1);
                    settings[0].Value.Should().Be("42");
                }
            }
        }
        public void TestCtor()
        {
            _settings.Add(new QuickFilter {
                Value = "foo"
            });
            _settings.Add(new QuickFilter {
                Value = "bar"
            });
            var quickFilters = new Tailviewer.BusinessLogic.Filters.QuickFilters(_settings);
            List <Tailviewer.BusinessLogic.Filters.QuickFilter> filters = quickFilters.Filters.ToList();

            filters.Count.Should().Be(2);
            filters[0].Id.Should().Be(_settings[0].Id);
            filters[0].Value.Should().Be("foo");
            filters[1].Id.Should().Be(_settings[1].Id);
            filters[1].Value.Should().Be("bar");
        }
 private void Add()
 {
     var filter = new Core.Settings.QuickFilter();
     var viewModel = new FilterViewModel(filter);
     viewModel.OnRemoved += FilterOnOnRemoved;
     _filters.Add(viewModel);
     _configuration.Add(filter);
 }
        public void TestRoundtripTwoFilters()
        {
            var filters = new QuickFilters();

            filters.Add(new QuickFilter
            {
                IgnoreCase = true,
                IsInverted = false,
                Value      = "A",
                MatchType  = FilterMatchType.TimeFilter
            });
            filters.Add(new QuickFilter
            {
                IgnoreCase = false,
                IsInverted = true,
                Value      = "B",
                MatchType  = FilterMatchType.SubstringFilter
            });

            var actualFilters = Roundtrip(filters);

            actualFilters.Should().NotBeNull();
            actualFilters.Should().HaveCount(2);

            actualFilters[0].Id.Should().Be(filters[0].Id);
            actualFilters[0].IgnoreCase.Should().BeTrue();
            actualFilters[0].IsInverted.Should().BeFalse();
            actualFilters[0].Value.Should().Be("A");
            actualFilters[0].MatchType.Should().Be(FilterMatchType.TimeFilter);

            actualFilters[1].Id.Should().Be(filters[1].Id);
            actualFilters[1].IgnoreCase.Should().BeFalse();
            actualFilters[1].IsInverted.Should().BeTrue();
            actualFilters[1].Value.Should().Be("B");
            actualFilters[1].MatchType.Should().Be(FilterMatchType.SubstringFilter);
        }
Exemple #5
0
 private void AddFilterBtn_Click(object sender, EventArgs e)
 {
     QuickFilters.Add(this.filterSearchTb.Text);
     UpdateFilterDropDown();
 }