private NodeValueClientFilter InitializeFilter(params IndexQuery[] filters) { NodeValueClientFilter filter = new NodeValueClientFilter(this, _node, _property, _read, filters); filter.Initialize(TestIndexDescriptorFactory.forLabel(11), this, null, IndexOrder.NONE, true); return(filter); }
private void ShouldConsultProvidedFilters(System.Func <Value[], Value[]> filterValues, bool filterAcceptsValue) { // given long nodeReference = 123; int labelId = 10; int slots = Random.Next(3, 8); IndexQuery[] filters = new IndexQuery[slots]; Value[] actualValues = new Value[slots]; Value[] values = new Value[slots]; IDictionary <int, Value> properties = new Dictionary <int, Value>(); int[] propertyKeyIds = new int[slots]; int filterCount = 0; for (int i = 0; i < slots; i++) { actualValues[i] = Random.nextValue(); int propertyKeyId = i; propertyKeyIds[i] = propertyKeyId; // we want at least one filter , randomly add filter or not if ((filterCount == 0 && i == slots - 1) || Random.nextBoolean()) { object filterValue = (filterAcceptsValue ? actualValues[i] : AnyOtherValueThan(actualValues[i])).asObjectCopy(); filters[i] = IndexQuery.exact(propertyKeyId, filterValue); filterCount++; } values[i] = Random.nextBoolean() ? NO_VALUE : actualValues[i]; properties[propertyKeyId] = actualValues[i]; } _node.withNode(nodeReference, new long[] { labelId }, properties); // when NodeValueClientFilter filter = new NodeValueClientFilter(this, _node, _property, _read, filters); filter.Initialize(TestIndexDescriptorFactory.forLabel(labelId, propertyKeyIds), this, null, IndexOrder.NONE, true); bool accepted = filter.AcceptNode(nodeReference, filterValues(values)); // then assertEquals(filterAcceptsValue, accepted); }