//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(Factory.class) void shouldWorkOnADifferentSetOfCommandsAfterClear(Factory factory)
        internal virtual void ShouldWorkOnADifferentSetOfCommandsAfterClear(Factory factory)
        {
            // given
            EntityCommandGrouper grouper = new EntityCommandGrouper <>(factory.command(0).GetType(), 16);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.impl.transaction.command.Command.BaseCommand<? extends org.neo4j.kernel.impl.store.record.PrimitiveRecord> entity0 = factory.command(0);
            Command.BaseCommand <PrimitiveRecord> entity0 = factory.command(0);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.impl.transaction.command.Command.BaseCommand<? extends org.neo4j.kernel.impl.store.record.PrimitiveRecord> entity1 = factory.command(1);
            Command.BaseCommand <PrimitiveRecord> entity1 = factory.command(1);
            grouper.add(entity0);
            grouper.add(entity1);
            grouper.add(Property(entity0.After));
            grouper.add(Property(entity1.After));
            grouper.clear();

            // when
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.impl.transaction.command.Command.BaseCommand<? extends org.neo4j.kernel.impl.store.record.PrimitiveRecord> entity2 = factory.command(2);
            Command.BaseCommand <PrimitiveRecord> entity2 = factory.command(2);
            Command.PropertyCommand entityProperty        = Property(entity2.After);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.impl.transaction.command.Command.BaseCommand<? extends org.neo4j.kernel.impl.store.record.PrimitiveRecord> entity3 = factory.command(3);
            Command.BaseCommand <PrimitiveRecord> entity3 = factory.command(3);
            grouper.add(entity2);
            grouper.add(entityProperty);
            grouper.add(entity3);

            // then
            AssertGroups(grouper.sortAndAccessGroups(), Group(entity2.Key, entity2, entityProperty), Group(entity3.Key, entity3));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(Factory.class) void shouldSeeMultipleGroupsSomeOfThemWithEntity(Factory factory)
        internal virtual void ShouldSeeMultipleGroupsSomeOfThemWithEntity(Factory factory)
        {
            // given
            EntityCommandGrouper grouper = new EntityCommandGrouper <>(factory.command(0).GetType(), 64);

            Group[] groups = new Group[_random.Next(10, 30)];
            for (int entityId = 0; entityId < groups.Length; entityId++)
            {
                Command.BaseCommand entityCommand = _random.nextBoolean() ? factory.command(entityId) : null;
                groups[entityId] = new Group(entityId, entityCommand);
                if (entityCommand != null)
                {
                    grouper.add(entityCommand);                                // <-- storage transaction logs are sorted such that entity commands comes before property commands
                }
            }
            int totalNumberOfProperties = _random.Next(10, 100);

            for (int i = 0; i < totalNumberOfProperties; i++)
            {
                int entityId = _random.Next(groups.Length);
                Command.PropertyCommand property = property(factory.command(entityId).After);
                groups[entityId].AddProperty(property);
                grouper.add(property);
            }
            // ^^^ OK so we've generated property commands for random entities in random order, let's sort them
            EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();

            // then
            AssertGroups(cursor, groups);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @EnumSource(Factory.class) void shouldSeeSingleGroupOfPropertiesWithoutEntity(Factory factory)
        internal virtual void ShouldSeeSingleGroupOfPropertiesWithoutEntity(Factory factory)
        {
            // given
            EntityCommandGrouper grouper = new EntityCommandGrouper <>(factory.command(0).GetType(), 8);
            long entityId = 1;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.kernel.impl.transaction.command.Command.BaseCommand<? extends org.neo4j.kernel.impl.store.record.PrimitiveRecord> entity = factory.command(entityId);
            Command.BaseCommand <PrimitiveRecord> entity = factory.command(entityId);
            Command.PropertyCommand property1            = Property(entity.After);
            Command.PropertyCommand property2            = Property(entity.After);
            // intentionally DO NOT add the entity command
            grouper.add(property1);
            grouper.add(property2);
            EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();

            // when/then
            AssertGroups(cursor, Group(entityId, null, property1, property2));
        }
 public CommandCompletedEvent(Command.BaseCommand command, DateTime eventDateTime) : this(command.Id, eventDateTime)
 {
     Command = command;
 }
 private Group Group <T1>(long entityId, Command.BaseCommand <T1> entityCommand, params Command.PropertyCommand[] properties) where T1 : Org.Neo4j.Kernel.impl.store.record.PrimitiveRecord
 {
     return(new Group(entityId, entityCommand, properties));
 }