//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSplitUpRelationshipTypesInBatches() public virtual void ShouldSplitUpRelationshipTypesInBatches() { // GIVEN int denseNodeThreshold = 5; int numberOfNodes = 100; int numberOfTypes = 10; NodeRelationshipCache cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, denseNodeThreshold); cache.NodeCount = numberOfNodes + 1; Direction[] directions = Direction.values(); for (int i = 0; i < numberOfNodes; i++) { int count = Random.Next(1, denseNodeThreshold * 2); cache.setCount(i, count, Random.Next(numberOfTypes), Random.among(directions)); } cache.CountingCompleted(); IList <RelationshipTypeCount> types = new List <RelationshipTypeCount>(); int numberOfRelationships = 0; for (int i = 0; i < numberOfTypes; i++) { int count = Random.Next(1, 100); types.Add(new RelationshipTypeCount(i, count)); numberOfRelationships += count; } types.sort((t1, t2) => Long.compare(t2.Count, t1.Count)); DataStatistics typeDistribution = new DataStatistics(0, 0, types.ToArray()); { // WHEN enough memory for all types long memory = cache.CalculateMaxMemoryUsage(numberOfRelationships) * numberOfTypes; int upToType = ImportLogic.NextSetOfTypesThatFitInMemory(typeDistribution, 0, memory, cache.NumberOfDenseNodes); // THEN assertEquals(types.Count, upToType); } { // and WHEN less than enough memory for all types long memory = cache.CalculateMaxMemoryUsage(numberOfRelationships) * numberOfTypes / 3; int startingFromType = 0; int rounds = 0; while (startingFromType < types.Count) { rounds++; startingFromType = ImportLogic.NextSetOfTypesThatFitInMemory(typeDistribution, startingFromType, memory, cache.NumberOfDenseNodes); } assertEquals(types.Count, startingFromType); assertThat(rounds, greaterThan(1)); } }