public void SetUp() { integrationTriggerMock = new LatchMock(typeof (ITrigger)); integrationTriggerMock.Strict = true; projectMock = new LatchMock(typeof (IProject)); projectMock.Strict = true; projectMock.SetupResult("Name", "project"); projectMock.SetupResult("QueueName", TestQueueName); projectMock.SetupResult("QueuePriority", 0); projectMock.SetupResult("Triggers", integrationTriggerMock.MockInstance); projectMock.SetupResult("WorkingDirectory", tempWorkingDir1); projectMock.SetupResult("ArtifactDirectory", tempArtifactDir1); integrationQueues = new IntegrationQueueSet(); integrationQueues.Add(TestQueueName, new DefaultQueueConfiguration(TestQueueName)); integrationQueue = integrationQueues[TestQueueName]; integrator = new ProjectIntegrator((IProject) projectMock.MockInstance, integrationQueue); }
public void CancellingAPendingRequestWhileNotBuildingGoesToSleeping() { LatchMock otherProjectMock = new LatchMock(typeof (IProject)); otherProjectMock.Strict = true; otherProjectMock.SetupResult("Name", "otherProject"); otherProjectMock.SetupResult("QueueName", TestQueueName); otherProjectMock.SetupResult("QueuePriority", 0); otherProjectMock.SetupResult("Triggers", integrationTriggerMock.MockInstance); otherProjectMock.SetupResult("WorkingDirectory", tempDir + "tempWorkingDir2"); otherProjectMock.SetupResult("ArtifactDirectory", tempDir + "tempArtifactDir2"); IProject otherProject = (IProject) otherProjectMock.MockInstance; IProject project = (IProject) projectMock.MockInstance; ProjectIntegrator otherIntegrator = new ProjectIntegrator(otherProject, integrationQueue); // Queue up the "otherProject" in the first queue position to build IntegrationRequest otherProjectRequest = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null); otherProjectMock.Expect("NotifyPendingState"); // Queue up our test project on the same queue as so it goes to pending IntegrationRequest request2 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null); projectMock.Expect("NotifyPendingState"); // Cancelling the pending request should revert status to sleeping projectMock.Expect("NotifySleepingState"); integrationTriggerMock.Expect("IntegrationCompleted"); integrationQueue.Enqueue(new IntegrationQueueItem(otherProject, otherProjectRequest, otherIntegrator)); integrationQueue.Enqueue(new IntegrationQueueItem(project, request2, integrator)); // Cancel second build project on queue integrator.CancelPendingRequest(); otherProjectMock.Verify(); VerifyAll(); }