Пример #1
0
        public void CanonNegatingFilter()
        {
            var canon = new FilterCanonicalizer();

            var tagFilter1 = new TagFilter(Tag("A"));
            var tagFilter2 = new TagFilter(Tag("A"));
            var tagFilter3 = new TagFilter(Tag("B"));

            var negatingFilter1 = new NegatingFilter(tagFilter1);
            var negatingFilter2 = new NegatingFilter(tagFilter2);
            var negatingFilter3 = new NegatingFilter(tagFilter3);

            var canonNegatingFilter1 = negatingFilter1.Canonicalize(canon);
            var canonNegatingFilter2 = negatingFilter2.Canonicalize(canon);
            var canonNegatingFilter3 = negatingFilter3.Canonicalize(canon);

            Assert.Same(canonNegatingFilter1, canonNegatingFilter2);
            Assert.NotSame(canonNegatingFilter1, canonNegatingFilter3);

            var canonTagFilter = tagFilter1.Canonicalize(canon);
            var canonFilter1   = canonNegatingFilter1 as NegatingFilter;
            var canonFilter2   = canonNegatingFilter2 as NegatingFilter;

            Assert.NotNull(canonFilter1);
            Assert.NotNull(canonFilter2);
            Assert.Same(canonFilter1.Inner, canonTagFilter);
            Assert.Same(canonFilter2.Inner, canonTagFilter);
        }
Пример #2
0
        public void CanonAndSimplifyBinaryFilter()
        {
            var canon = new FilterCanonicalizer();

            var negatingFilter1 = new NegatingFilter(new TagFilter(Tag("B")));
            var negatingFilter2 = new NegatingFilter(new TagFilter(Tag("B")));

            var binaryFilter = new BinaryFilter(negatingFilter1, FilterOperator.And, negatingFilter2);
            var canonFilter  = binaryFilter.Canonicalize(canon);

            Assert.Same(canonFilter, negatingFilter1.Canonicalize(canon));
        }