public void TestGreaterThanFilter()
        {
            GreaterThanFilter v1 = new GreaterThanFilter(ConnectorAttributeBuilder.Build("foo", "bar"));
            GreaterThanFilter v2 = (GreaterThanFilter)CloneObject(v1);

            Assert.AreEqual(v1.GetAttribute(), v2.GetAttribute());
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public string VisitGreaterThanFilter(Hashtable p, GreaterThanFilter filter)
        {
            var name  = filter.GetName();
            var name2 = name as String;

            if (p.ContainsKey(name))
            {
                name2 = p[name] as String;
            }
            return(string.Format("{0} -gt {1}", name2, filter.GetValue()));
        }
        public void ReturnFalseIfNotGreaterThan()
        {
            var e = new SystemEvent {
                ProcessId = 50
            };
            var extendedProperties = new FakeExtendedProperties {
                { "property", "ProcessId" }, { "value", "50" }
            };
            var filter = new GreaterThanFilter(extendedProperties, Enumerable.Empty <ICreateFilterExpressions>());

            Assert.False(Filter.Compile(filter).Invoke(e));
        }
        public void TestGreaterThanFilter_NullableDouble_ValueIsLessThan()
        {
            var instance = new GreaterThanFilterTestClass
            {
                NullableD = 1.0
            };
            var list = new List <GreaterThanFilterTestClass>();

            list.Add(instance);

            var filter = new GreaterThanFilter <GreaterThanFilterTestClass>("NullableD", instance.NullableD.Value - 1.0);

            var where = filter.ToWhereExpression();
            var results = list.Where(where.Compile()).ToList();

            Assert.AreEqual(1, results.Count);
        }
        public void TestGreaterThanFilter_NonNullableInt_ValueIsGreater()
        {
            var instance = new GreaterThanFilterTestClass
            {
                Int = 1
            };
            var list = new List <GreaterThanFilterTestClass>();

            list.Add(instance);

            var filter = new GreaterThanFilter <GreaterThanFilterTestClass>("Int", instance.Int + 1);

            var where = filter.ToWhereExpression();
            var results = list.Where(where.Compile()).ToList();

            Assert.AreEqual(0, results.Count);
        }
        public void TestGreaterThanFilter_NullableDecimal_ValueIsGreater()
        {
            var instance = new GreaterThanFilterTestClass
            {
                NullableDec = 1.0m
            };
            var list = new List <GreaterThanFilterTestClass>();

            list.Add(instance);

            var filter = new GreaterThanFilter <GreaterThanFilterTestClass>("NullableDec", instance.NullableDec.Value + 1.0m);

            var where = filter.ToWhereExpression();
            var results = list.Where(where.Compile()).ToList();

            Assert.AreEqual(0, results.Count);
        }
        public void TestGreaterThanFilter_NullableDateTimeOffset_ValueIsGreater()
        {
            var instance = new GreaterThanFilterTestClass
            {
                NullableDTOffset = DateTimeOffset.Now
            };
            var list = new List <GreaterThanFilterTestClass>();

            list.Add(instance);

            var filter = new GreaterThanFilter <GreaterThanFilterTestClass>("NullableDTOffset", instance.NullableDTOffset.Value.AddDays(1.0));

            var where = filter.ToWhereExpression();
            var results = list.Where(where.Compile()).ToList();

            Assert.AreEqual(0, results.Count);
        }
        public void TestGreaterThanFilter_NullableDate_ValueIsEqual()
        {
            var instance = new GreaterThanFilterTestClass
            {
                NullableDate = DateTime.UtcNow
            };
            var list = new List <GreaterThanFilterTestClass>();

            list.Add(instance);

            var filter = new GreaterThanFilter <GreaterThanFilterTestClass>("NullableDate", instance.NullableDate);

            var where = filter.ToWhereExpression();
            var results = list.Where(where.Compile()).ToList();

            Assert.AreEqual(0, results.Count);
        }
        protected override String CreateGreaterThanExpression(GreaterThanFilter filter,
                                                              Boolean not)
        {
            // Note that (!(a > X)) is only the same as (a <= X) if every object
            // has a value of a.
            if (not)
            {
                return(null);
            }

            String[] attrNames = GetLdapNamesForAttribute(filter.GetAttribute());
            if (attrNames == null)
            {
                return(null);
            }

            StringBuilder builder = new StringBuilder();

            BuildGreaterOrEqualFilter(builder, attrNames, filter.GetValue());
            return(builder.ToString());
        }
Example #10
0
 public void TestGreaterThanFilter()
 {
     GreaterThanFilter v1 = new GreaterThanFilter(ConnectorAttributeBuilder.Build("foo", "bar"));
     GreaterThanFilter v2 = (GreaterThanFilter)CloneObject(v1);
     Assert.AreEqual(v1.GetAttribute(), v2.GetAttribute());
 }
Example #11
0
 public Dictionary <string, object> VisitGreaterThanFilter(Hashtable p, GreaterThanFilter filter)
 {
     return(CreateMap("GREATERTHAN", filter.GetName(), filter.GetValue()));
 }
        public void NotCompositeExpression()
        {
            var filter = new GreaterThanFilter(new FakeExtendedProperties(), Enumerable.Empty <ICreateFilterExpressions>());

            Assert.False(filter.CompositeExpression);
        }
Example #13
0
 public string VisitGreaterThanFilter(Hashtable p, GreaterThanFilter filter)
 {
     throw new NotImplementedException();
 }
Example #14
0
 /// <summary>
 /// Generates the text for a GreaterThanFilter builder.
 /// </summary>
 /// <param name="item">The GreaterThanFilter builder to generate the text for.</param>
 protected internal override void VisitGreaterThanFilter(GreaterThanFilter item)
 {
     visitOrderedFilter(item, ">");
 }
Example #15
0
 protected override Filter CreateGreaterThanExpression(GreaterThanFilter filter, bool not)
 {
     return(not ? FilterBuilder.Not(filter) : filter);
 }
Example #16
0
 protected override IDictionary <String, Object> CreateGreaterThanExpression(GreaterThanFilter filter, Boolean not)
 {
     return(CreateFilter("GREATERTHAN", filter, not));
 }
 protected override void VisitGreaterThanFilter(GreaterThanFilter item)
 {
     VisitOrderFilter(item);
 }
Example #18
0
        protected override String CreateGreaterThanExpression(GreaterThanFilter filter, bool not)
        {
            String rv = "( > " + filter.GetName() + " " + filter.GetValue() + " )";

            return(Not(rv, not));
        }