//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotStartOtherSamplingWhenSamplingAllTheIndexes()
        public virtual void ShouldNotStartOtherSamplingWhenSamplingAllTheIndexes()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger totalCount = new java.util.concurrent.atomic.AtomicInteger(0);
            AtomicInteger totalCount = new AtomicInteger(0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger concurrentCount = new java.util.concurrent.atomic.AtomicInteger(0);
            AtomicInteger concurrentCount = new AtomicInteger(0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.DoubleLatch jobLatch = new org.neo4j.test.DoubleLatch();
            DoubleLatch jobLatch = new DoubleLatch();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.test.DoubleLatch testLatch = new org.neo4j.test.DoubleLatch();
            DoubleLatch testLatch = new DoubleLatch();

            IndexSamplingJobFactory jobFactory = (_indexId, proxy) =>
            {
                if (!concurrentCount.compareAndSet(0, 1))
                {
                    throw new System.InvalidOperationException("count !== 0 on create");
                }
                totalCount.incrementAndGet();
                jobLatch.WaitForAllToStart();
                testLatch.StartAndWaitForAllToStart();
                jobLatch.WaitForAllToFinish();
                concurrentCount.decrementAndGet();
                testLatch.Finish();
                return(null);
            };

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexSamplingController controller = new IndexSamplingController(samplingConfig, jobFactory, jobQueue, tracker, snapshotProvider, scheduler, always(true));
            IndexSamplingController controller = new IndexSamplingController(_samplingConfig, jobFactory, _jobQueue, _tracker, _snapshotProvider, _scheduler, Always(true));

            when(_tracker.canExecuteMoreSamplingJobs()).thenReturn(true);
            when(_indexProxy.State).thenReturn(ONLINE);

            // when running once
            (new Thread(RunController(controller, TRIGGER_REBUILD_UPDATED))).Start();

            jobLatch.StartAndWaitForAllToStart();
            testLatch.WaitForAllToStart();

            // then blocking on first job
            assertEquals(1, concurrentCount.get());

            // when running a second time
            controller.SampleIndexes(BACKGROUND_REBUILD_UPDATED);

            // then no concurrent job execution
            jobLatch.Finish();
            testLatch.WaitForAllToFinish();

            // and finally exactly one job has run to completion
            assertEquals(0, concurrentCount.get());
            assertEquals(1, totalCount.get());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotStartAJobIfTheTrackerCannotHandleIt()
        public virtual void ShouldNotStartAJobIfTheTrackerCannotHandleIt()
        {
            // given
            IndexSamplingController controller = NewSamplingController(Always(false));

            when(_tracker.canExecuteMoreSamplingJobs()).thenReturn(false);
            when(_indexProxy.State).thenReturn(ONLINE);

            // when
            controller.SampleIndexes(BACKGROUND_REBUILD_UPDATED);

            // then
            verify(_tracker, times(1)).canExecuteMoreSamplingJobs();
            verifyNoMoreInteractions(_jobFactory, _tracker);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStartASamplingJobForEachIndexInTheDB()
        public virtual void ShouldStartASamplingJobForEachIndexInTheDB()
        {
            // given
            IndexSamplingController controller = NewSamplingController(Always(false));

            when(_tracker.canExecuteMoreSamplingJobs()).thenReturn(true);
            when(_indexProxy.State).thenReturn(ONLINE);

            // when
            controller.SampleIndexes(BACKGROUND_REBUILD_UPDATED);

            // then
            verify(_jobFactory).create(_indexId, _indexProxy);
            verify(_tracker).scheduleSamplingJob(_job);
            verify(_tracker, times(2)).canExecuteMoreSamplingJobs();
            verifyNoMoreInteractions(_jobFactory, _tracker);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSampleAllTheOnlineIndexes()
        public virtual void ShouldSampleAllTheOnlineIndexes()
        {
            // given
            IndexSamplingController controller = NewSamplingController(Always(false));

            when(_tracker.canExecuteMoreSamplingJobs()).thenReturn(true);
            when(_indexProxy.State).thenReturn(ONLINE);
            when(_anotherIndexProxy.State).thenReturn(POPULATING);
            _indexMap.putIndexProxy(_anotherIndexProxy);

            // when
            controller.SampleIndexes(TRIGGER_REBUILD_UPDATED);

            // then
            verify(_jobFactory).create(_indexId, _indexProxy);
            verify(_tracker).scheduleSamplingJob(_job);

            verify(_tracker, times(2)).waitUntilCanExecuteMoreSamplingJobs();
            verifyNoMoreInteractions(_jobFactory, _tracker);
        }