private object[] GeneratePropertyValues(string[] propKeys, int keySizeLimitPerSlot, int wiggleRoomPerSlot) { object[] propValues = new object[propKeys.Length]; for (int propKey = 0; propKey < propKeys.Length; propKey++) { NamedDynamicValueGenerator among = Random.among(NamedDynamicValueGenerator.values()); propValues[propKey] = among.dynamicValue(keySizeLimitPerSlot, wiggleRoomPerSlot); } return(propValues); }
/// <summary> /// Key size validation test for single type. /// /// Validate that we handle index reads and writes correctly for dynamically sized values (arrays and strings) /// of all different types with length close to and over the max limit for given type. /// /// We do this by inserting arrays of increasing size (doubling each iteration) and when we hit the upper limit /// we do binary search between the established min and max limit. /// We also verify that the largest successful array length for each type is as expected because this value /// is documented and if it changes, documentation also needs to change. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldEnforceSizeCapSingleValueSingleType() public virtual void ShouldEnforceSizeCapSingleValueSingleType() { NamedDynamicValueGenerator[] dynamicValueGenerators = NamedDynamicValueGenerator.values(); foreach (NamedDynamicValueGenerator generator in dynamicValueGenerators) { string propKey = _propKeys[0] + generator.name(); CreateIndex(propKey); BinarySearch binarySearch = new BinarySearch(this); object propValue; while (!binarySearch.Finished()) { propValue = generator.dynamicValue(binarySearch.ArrayLength); long expectedNodeId = -1; // Write bool wasAbleToWrite = true; try { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(LABEL_ONE); node.SetProperty(propKey, propValue); expectedNodeId = node.Id; tx.Success(); } } catch (Exception) { wasAbleToWrite = false; } // Read VerifyReadExpected(propKey, propValue, expectedNodeId, wasAbleToWrite); // Progress binary search binarySearch.Progress(wasAbleToWrite); } assertEquals(format("expected longest successful array length for type %s, to be %d but was %d. " + "This is a strong indication that documentation of max limit needs to be updated.", generator.name(), generator.expectedMax, binarySearch.LongestSuccessful), generator.expectedMax, binarySearch.LongestSuccessful); } }