public void TestExtract() { IValueExtractor extractor = new ReflectionExtractor("getId"); IFilter filter = new GreaterFilter(extractor, 5); var person = new Person("123456789", DateTime.Now); var condExtractor = new ConditionalExtractor(filter, extractor, true); condExtractor.Extract(person); }
/// <summary> /// Compare the ConditionalExtractor with another object to determine /// equality. /// </summary> /// <remarks> /// Two ConditionalExtractor objects are considered equal iff their /// underlying <b>IFilters</b>, <b>IValueExtractors</b> and support /// for forward indices are equal. /// </remarks> /// <param name="o"> /// The reference object with which to compare. /// </param> /// <returns> /// <b>true</b> if this ConditionalExtractor and the passed object are /// equivalent. /// </returns> public override bool Equals(object o) { if (o is ConditionalExtractor) { ConditionalExtractor that = (ConditionalExtractor)o; return(Equals(Filter, that.Filter) && Equals(Extractor, that.Extractor) && IsForwardIndexSupported == that.IsForwardIndexSupported); } return(false); }
public void TestCreateIndex() { IValueExtractor extractor = new IdentityExtractor(); IFilter filter = new GreaterFilter(extractor, 5); IDictionary map = new HashDictionary(); var condExtractor = new ConditionalExtractor(filter, extractor, true); var index = condExtractor.CreateIndex(false, null, map); Assert.IsTrue(index is ConditionalIndex); Assert.AreEqual(filter, ((ConditionalIndex)index).Filter); Assert.AreEqual(extractor, index.ValueExtractor); // make sure that the index map has been updated with the created // index var index2 = map[extractor] as ICacheIndex; Assert.IsNotNull(index2); Assert.AreEqual(index, index2); }
public void testCoh5516() { IFilter typeFilter = new EqualsFilter("getType", "bird"); IValueExtractor intExtractor = new ReflectionExtractor("getWings"); var condExtractor = new ConditionalExtractor(typeFilter, intExtractor, false); IDictionary map = new HashDictionary(); var index = condExtractor.CreateIndex(false, null, map); var bird = new Bird(); var fish = new Fish(); var entry1 = new CacheEntry(0, bird, bird); var entry2 = new CacheEntry(1, fish, fish); // add entries of type Fish and Bird - only the Bird should get indexed index.Insert(entry1); index.Insert(entry2); // remove entries of type Fish and Bird - only the Bird should get indexed index.Delete(entry1); index.Delete(entry2); }
public void TestDestroyIndex() { IValueExtractor extractor = new IdentityExtractor(); IFilter filter = new GreaterFilter(extractor, 5); IDictionary map = new HashDictionary(); var condExtractor = new ConditionalExtractor(filter, extractor, true); var index = condExtractor.CreateIndex(false, null, map); // make sure that the index map has been updated with the created // index var index2 = map[extractor] as ICacheIndex; Assert.IsNotNull(index2); Assert.AreEqual(index, index2); condExtractor.DestroyIndex(map); // make sure that the index has been removed from the index map Assert.IsNull(map[extractor]); }