コード例 #1
0
        public void TestAndContainingOr()
        {
            var filter = new OrPredicate <string> {
                new Predicate <string> {
                    Expression = (ev) => true
                },
                new Predicate <string> {
                    Expression = (ev) => false
                },
            };

            var filter2 = new OrPredicate <string> {
                new Predicate <string> {
                    Expression = (ev) => true
                },
                new Predicate <string> {
                    Expression = (ev) => false
                },
            };

            var container = new AndPredicate <string> ();

            container.Add(filter);
            container.Add(filter2);

            Assert.IsTrue(container.Filter(""));
        }
コード例 #2
0
        public void TestAndContainingOrSetActive()
        {
            // Arrange
            var filter = new OrPredicate <string> {
                new Predicate <string> {
                    Expression = (ev) => true
                },
                new Predicate <string> {
                    Expression = (ev) => true
                },
            };

            var filter2 = new OrPredicate <string> {
                new Predicate <string> {
                    Expression = (ev) => true
                },
                new Predicate <string> {
                    Expression = (ev) => true
                },
            };

            var container = new AndPredicate <string> ();

            container.Add(filter);
            container.Add(filter2);

            // Act
            filter2.Active = false;

            // Assert
            Assert.IsFalse(filter2 [0].Active);
            Assert.IsFalse(filter2 [1].Active);
            Assert.IsTrue(container.Filter(""));
        }
コード例 #3
0
        public void TestAndContainingInactiveOr()
        {
            var filter = new OrPredicate <string> {
                new Predicate <string> {
                    Expression = (ev) => true
                },
                new Predicate <string> {
                    Expression = (ev) => false
                },
            };

            filter.Active = false;

            var filter2 = new OrPredicate <string> {
                new Predicate <string> {
                    Expression = (ev) => true
                },
                new Predicate <string> {
                    Expression = (ev) => false
                },
            };

            var container = new AndPredicate <string> ();

            container.Add(filter);
            container.Add(filter2);

            Assert.IsFalse(filter.Elements [0].Active);
            Assert.IsFalse(filter.Elements [1].Active);
            Assert.IsFalse(filter.Filter(""));
            Assert.IsTrue(filter2.Filter(""));
            Assert.IsTrue(container.Filter(""));
        }
コード例 #4
0
        public void TestAndFalse()
        {
            var filter = new AndPredicate <string> {
                new Predicate <string> {
                    Expression = (ev) => true
                },
                new Predicate <string> {
                    Expression = (ev) => false
                },
            };

            Assert.IsFalse(filter.Filter(""));
        }
コード例 #5
0
        public void TestAndContainingEmptyOr()
        {
            var filter = new OrPredicate <string> {
                new Predicate <string> {
                    Expression = PredicateBuilder.True <string>()
                },
            };

            // This OR doesn't have any active Predicate, thus it's ignored
            var filter2 = new OrPredicate <string> ();

            var container = new AndPredicate <string> ();

            container.Add(filter);
            container.Add(filter2);

            Assert.IsTrue(container.Filter(""));
        }
コード例 #6
0
        public void TestAndOrEmpty()
        {
            // Arrange
            var filter  = new OrPredicate <string> ();
            var filter2 = new OrPredicate <string> ();

            var container = new AndPredicate <string> ();

            container.Add(filter);
            container.Add(filter2);

            // Act

            // Assert
            Assert.IsFalse(filter.Active);
            Assert.IsFalse(filter2.Active);
            Assert.IsFalse(container.Active);
            Assert.IsTrue(container.Filter(""));
        }