コード例 #1
0
        public void GitMaintenanceQueueStopSuceedsWhenQueueIsEmpty()
        {
            this.TestSetup();

            GitMaintenanceQueue queue = new GitMaintenanceQueue(this.context);

            queue.Stop();

            TestGitMaintenanceStep step = new TestGitMaintenanceStep(this.context, this.gitObjects);
            queue.TryEnqueue(step).ShouldEqual(false);
        }
コード例 #2
0
        public void GitMaintenanceQueueHandlesTwoJobs()
        {
            this.TestSetup();

            TestGitMaintenanceStep step1 = new TestGitMaintenanceStep(this.context);
            TestGitMaintenanceStep step2 = new TestGitMaintenanceStep(this.context);

            GitMaintenanceQueue queue = new GitMaintenanceQueue(this.context);

            queue.TryEnqueue(step1);
            queue.TryEnqueue(step2);

            step1.EventTriggered.WaitOne(this.maxWaitTime).ShouldBeTrue();
            step2.EventTriggered.WaitOne(this.maxWaitTime).ShouldBeTrue();

            queue.Stop();

            step1.NumberOfExecutions.ShouldEqual(1);
            step2.NumberOfExecutions.ShouldEqual(1);
        }
コード例 #3
0
        public void GitMaintenanceQueueEnlistmentRootReady()
        {
            this.TestSetup();

            GitMaintenanceQueue queue = new GitMaintenanceQueue(this.context);
            queue.EnlistmentRootReady().ShouldBeTrue();

            this.fileSystem.Paths.Remove(this.enlistment.EnlistmentRoot);
            queue.EnlistmentRootReady().ShouldBeFalse();

            this.fileSystem.Paths.Remove(this.enlistment.GitObjectsRoot);
            queue.EnlistmentRootReady().ShouldBeFalse();

            this.fileSystem.Paths.Add(this.enlistment.EnlistmentRoot);
            queue.EnlistmentRootReady().ShouldBeFalse();

            this.fileSystem.Paths.Add(this.enlistment.GitObjectsRoot);
            queue.EnlistmentRootReady().ShouldBeTrue();

            queue.Stop();
        }
コード例 #4
0
        public void GitMaintenanceQueueStopsJob()
        {
            this.TestSetup();

            GitMaintenanceQueue queue = new GitMaintenanceQueue(this.context);

            // This step stops the queue after the step is started,
            // then checks if Stop() was called.
            WatchForStopStep watchForStop = new WatchForStopStep(queue, this.context, this.gitObjects);

            queue.TryEnqueue(watchForStop);
            Assert.IsTrue(watchForStop.EventTriggered.WaitOne(this.maxWaitTime));
            watchForStop.SawStopping.ShouldBeTrue();

            // Ensure we don't start a job after the Stop() call
            TestGitMaintenanceStep watchForStart = new TestGitMaintenanceStep(this.context, this.gitObjects);
            queue.TryEnqueue(watchForStart).ShouldBeFalse();

            // This only ensures the event didn't happen within maxWaitTime
            Assert.IsFalse(watchForStart.EventTriggered.WaitOne(this.maxWaitTime));

            queue.Stop();
        }
コード例 #5
0
 public WatchForStopStep(GitMaintenanceQueue queue, GSDContext context)
     : base(context, requireObjectCacheLock: true)
 {
     this.Queue          = queue;
     this.EventTriggered = new ManualResetEvent(false);
 }