public void testArray() { LocalCache cache = new LocalCache(); cache.Clear(); cache.AddIndex(IdentityExtractor.Instance, false, null); DoPutALL doDoPutAll = new DoPutALL(cache, "array"); lock (doDoPutAll.m_myLock) { Thread thread = new Thread(new ThreadStart(doDoPutAll.Run)); thread.Start(); Thread.Sleep(2222); ArrayList qname = new ArrayList(); qname.Add("test"); IFilter filter = new ContainsAnyFilter(IdentityExtractor.Instance, (ICollection)qname); for (int i = 0; i < 50000; i++) { object[] result = cache.GetEntries(filter); Assert.AreEqual(result.Length, cache.Count); } // signal the PutAll thread to stop Monitor.Wait(doDoPutAll.m_myLock); thread.Join(); } }
public void TestToWhereExpression_ExceededMaxTerms() { var ints = new List <int>(); for (var i = 0; i <= ContainsAnyFilter <ContainsFilterTestClass> .MAX_TERMS; i++) { ints.Add(i); } var instance = new ContainsAnyFilter <ContainsFilterTestClass>("Ids", ints); instance.Invoking(x => x.ToWhereExpression()) .ShouldThrow <NotSupportedException>() .WithMessage(String.Format("The maximum number of terms to filter with is [{0}].", ContainsAnyFilter <ContainsFilterTestClass> .MAX_TERMS)); }
public void TestToWhereExpression_IntProperty_EmptyFilterValues() { var list = new List <ContainsFilterTestClass>(); list.Add(new ContainsFilterTestClass { Ids = new List <int> { 1, 2 } }); var testIds = new List <int>(); var filter = new ContainsAnyFilter <ContainsFilterTestClass>("Ids", testIds); filter.Invoking(x => x.ToWhereExpression()).ShouldThrow <NotSupportedException>() .WithMessage("There must be at least one value to filter on."); }
public void TestToWhereExpression_StringProperty_EmptyFilterValues() { var list = new List <ContainsFilterTestClass>(); list.Add(new ContainsFilterTestClass { Strings = new List <string> { "A", "B" } }); var testStrings = new List <string>(); var filter = new ContainsAnyFilter <ContainsFilterTestClass>("Strings", testStrings); filter.Invoking(x => x.ToWhereExpression()).ShouldThrow <NotSupportedException>() .WithMessage("There must be at least one value to filter on."); }
public void TestToWhereExpression_IntProperty_EmptyPropertyValues() { var list = new List <ContainsFilterTestClass>(); list.Add(new ContainsFilterTestClass { Ids = new List <int>() }); var testIds = new List <int> { 1, 2 }; var filter = new ContainsAnyFilter <ContainsFilterTestClass>("Ids", testIds); var where = filter.ToWhereExpression(); var results = list.Where(where.Compile()).ToList(); Assert.AreEqual(0, results.Count); }
public void TestToWhereExpression_StringProperty_EmptyPropertyValues() { var list = new List <ContainsFilterTestClass>(); list.Add(new ContainsFilterTestClass { Strings = new List <string>() }); var testStrings = new List <string> { "A" }; var filter = new ContainsAnyFilter <ContainsFilterTestClass>("Strings", testStrings); var where = filter.ToWhereExpression(); var results = list.Where(where.Compile()).ToList(); Assert.AreEqual(0, results.Count); }
public void TestToWhereExpression_LongProperty_IntValues() { var list = new List <ContainsFilterTestClass>(); list.Add(new ContainsFilterTestClass { LongIds = new List <long> { 1L } }); var testIds = new List <int> { 1 }; var filter = new ContainsAnyFilter <ContainsFilterTestClass>("LongIds", testIds); var where = filter.ToWhereExpression(); var results = list.Where(where.Compile()).ToList(); Assert.AreEqual(1, results.Count); }
public void TestPropertyCollectionType_PropertyIsInt_ValueIsLong() { var filter = new ContainsAnyFilter <ContainsFilterTestClass>("Ids", new List <long>()); Assert.AreEqual(typeof(Int32), filter.ValueCollectionType); }
public void TestValueCollectionType() { var filter = new ContainsAnyFilter <ContainsFilterTestClass>("Ids", new List <int>()); Assert.AreEqual(typeof(int), filter.ValueCollectionType); }