public void GetIntegrationQueueSnapshotForSingleProjectOnSingleQueue()
        {
            project1Mock.SetupResult("CurrentActivity", ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue1.Enqueue(integrationQueueItem1);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

            Assert.IsNotNull(queueSetSnapshot);
            Assert.AreEqual(2, queueSetSnapshot.Queues.Count);

            QueueSnapshot queueSnapshot = queueSetSnapshot.Queues[0];

            Assert.IsNotNull(queueSnapshot);
            Assert.IsFalse(queueSnapshot.IsEmpty);
            Assert.AreEqual(TestQueueName, queueSnapshot.QueueName);
            Assert.AreEqual(1, queueSnapshot.Requests.Count);
            Assert.AreEqual(queueSnapshot, queueSetSnapshot.FindByName(TestQueueName));

            QueuedRequestSnapshot queuedRequestSnapshot = queueSnapshot.Requests[0];

            Assert.AreEqual("ProjectOne", queuedRequestSnapshot.ProjectName);
            Assert.AreEqual(ProjectActivity.CheckingModifications, queuedRequestSnapshot.Activity);

            QueueSnapshot queueSnapshot2 = queueSetSnapshot.Queues[1];

            Assert.IsNotNull(queueSnapshot2);
            Assert.IsTrue(queueSnapshot2.IsEmpty);

            VerifyAll();
        }
Example #2
0
        public void GetIntegrationQueueSnapshotForSingleProjectOnSingleQueue()
        {
            project1Mock.SetupGet(project => project.CurrentActivity).Returns(ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueue1.Enqueue(integrationQueueItem1);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

            Assert.IsNotNull(queueSetSnapshot);
            Assert.AreEqual(2, queueSetSnapshot.Queues.Count);

            QueueSnapshot queueSnapshot = queueSetSnapshot.Queues[0];

            Assert.IsNotNull(queueSnapshot);
            Assert.IsFalse(queueSnapshot.IsEmpty);
            Assert.AreEqual(TestQueueName, queueSnapshot.QueueName);
            Assert.AreEqual(1, queueSnapshot.Requests.Count);
            Assert.AreEqual(queueSnapshot, queueSetSnapshot.FindByName(TestQueueName));

            QueuedRequestSnapshot queuedRequestSnapshot = queueSnapshot.Requests[0];

            Assert.AreEqual("ProjectOne", queuedRequestSnapshot.ProjectName);
            Assert.AreEqual(ProjectActivity.CheckingModifications, queuedRequestSnapshot.Activity);

            QueueSnapshot queueSnapshot2 = queueSetSnapshot.Queues[1];

            Assert.IsNotNull(queueSnapshot2);
            Assert.IsTrue(queueSnapshot2.IsEmpty);

            VerifyAll();
            queueNotifier1Mock.VerifyNoOtherCalls();
        }
Example #3
0
        public void AddingADuplicateProjectWithForceBuildReAddsToTop()
        {
            // Setup the first project request
            project1Mock.SetupResult("QueueName", integrationQueueReAddTop.Name);
            project1Mock.SetupResult("QueuePriority", 1);
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            integrationQueueReAddTop.Enqueue(integrationQueueItem1);

            // Add a second project request for different project with same queue name
            project2Mock.SetupResult("QueueName", integrationQueueReAddTop.Name);
            project2Mock.SetupResult("QueuePriority", 0);
            queueNotifier2Mock.Expect("NotifyEnteringIntegrationQueue");
            integrationQueueReAddTop.Enqueue(integrationQueueItem4);

            // Add a third project request for different project with same queue name
            project3Mock.SetupResult("QueueName", integrationQueueReAddTop.Name);
            project3Mock.SetupResult("QueuePriority", 0);
            queueNotifier3Mock.Expect("NotifyEnteringIntegrationQueue");
            integrationQueueReAddTop.Enqueue(integrationQueueItem3);

            // Now add the second project request again, but with a force build
            project2Mock.SetupResult("QueueName", integrationQueueReAddTop.Name);
            project2Mock.SetupResult("QueuePriority", 0);
            queueNotifier2Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier2Mock.Expect("NotifyExitingIntegrationQueue", true);
            integrationQueueReAddTop.Enqueue(integrationQueueItem2);

            // Check the queued items
            IIntegrationQueueItem[] queuedItems = integrationQueueReAddTop.GetQueuedIntegrations();
            Assert.AreEqual(integrationQueueItem2, queuedItems[1], "Integration item #1 is incorrect");
            Assert.AreEqual(integrationQueueItem3, queuedItems[2], "Integration item #2 is incorrect");
            VerifyAll();
        }
        public void AddingADuplicateProjectWithForceBuildReplaces()
        {
            // Setup the first project request
            project1Mock.SetupGet(project => project.QueueName).Returns(integrationQueueReplace.Name);
            project1Mock.SetupGet(project => project.QueuePriority).Returns(1);
            queueNotifier1Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueueReplace.Enqueue(integrationQueueItem1);

            // Add a second project request for different project with same queue name
            project2Mock.SetupGet(project => project.QueueName).Returns(integrationQueueReplace.Name);
            project2Mock.SetupGet(project => project.QueuePriority).Returns(0);
            queueNotifier2Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueueReplace.Enqueue(integrationQueueItem4);

            // Add a third project request for different project with same queue name
            project3Mock.SetupGet(project => project.QueueName).Returns(integrationQueueReplace.Name);
            project3Mock.SetupGet(project => project.QueuePriority).Returns(0);
            queueNotifier3Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueueReplace.Enqueue(integrationQueueItem3);

            // Now add the second project request again, but with a force build
            project2Mock.SetupGet(project => project.QueueName).Returns(integrationQueueReplace.Name);
            project2Mock.SetupGet(project => project.QueuePriority).Returns(0);
            queueNotifier2Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            queueNotifier2Mock.Setup(notifier => notifier.NotifyExitingIntegrationQueue(true)).Verifiable();
            integrationQueueReplace.Enqueue(integrationQueueItem2);

            // Check the queued items
            IIntegrationQueueItem[] queuedItems = integrationQueueReplace.GetQueuedIntegrations();
            Assert.AreEqual(integrationQueueItem2, queuedItems[1], "Integration item #1 is incorrect");
            Assert.AreEqual(integrationQueueItem3, queuedItems[2], "Integration item #2 is incorrect");
            VerifyAll();
        }
        public void GetIntegrationQueueSnapshotForMultipleQueues()
        {
            project1Mock.SetupResult("CurrentActivity", ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue1.Enqueue(integrationQueueItem1);

            // Second item is different project and different queue
            project2Mock.SetupResult("CurrentActivity", ProjectActivity.Pending);
            queueNotifier2Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier2Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue2.Enqueue(integrationQueueItem2);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

            Assert.AreEqual(2, queueSetSnapshot.Queues.Count);

            foreach (QueueSnapshot namedQueueSnapshot in queueSetSnapshot.Queues)
            {
                Assert.AreEqual(1, namedQueueSnapshot.Requests.Count);
            }

            QueueSnapshot firstQueueSnapshot = queueSetSnapshot.Queues[0];

            Assert.AreEqual(1, firstQueueSnapshot.Requests.Count);
            QueuedRequestSnapshot firstQueuedRequestSnapshot = firstQueueSnapshot.Requests[0];

            Assert.AreEqual("ProjectOne", firstQueuedRequestSnapshot.ProjectName);

            QueueSnapshot secondQueueSnapshot = queueSetSnapshot.Queues[1];

            Assert.AreEqual(1, secondQueueSnapshot.Requests.Count);
            QueuedRequestSnapshot secondQueuedRequestSnapshot = secondQueueSnapshot.Requests[0];

            Assert.AreEqual("ProjectTwo", secondQueuedRequestSnapshot.ProjectName);

            VerifyAll();
        }
Example #6
0
        public void GetIntegrationQueueSnapshotForMultipleQueues()
        {
            project1Mock.SetupGet(project => project.CurrentActivity).Returns(ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueue1.Enqueue(integrationQueueItem1);

            // Second item is different project and different queue
            project2Mock.SetupGet(project => project.CurrentActivity).Returns(ProjectActivity.Pending);
            queueNotifier2Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueue2.Enqueue(integrationQueueItem2);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

            Assert.AreEqual(2, queueSetSnapshot.Queues.Count);

            foreach (QueueSnapshot namedQueueSnapshot in queueSetSnapshot.Queues)
            {
                Assert.AreEqual(1, namedQueueSnapshot.Requests.Count);
            }

            QueueSnapshot firstQueueSnapshot = queueSetSnapshot.Queues[0];

            Assert.AreEqual(1, firstQueueSnapshot.Requests.Count);
            QueuedRequestSnapshot firstQueuedRequestSnapshot = firstQueueSnapshot.Requests[0];

            Assert.AreEqual("ProjectOne", firstQueuedRequestSnapshot.ProjectName);

            QueueSnapshot secondQueueSnapshot = queueSetSnapshot.Queues[1];

            Assert.AreEqual(1, secondQueueSnapshot.Requests.Count);
            QueuedRequestSnapshot secondQueuedRequestSnapshot = secondQueueSnapshot.Requests[0];

            Assert.AreEqual("ProjectTwo", secondQueuedRequestSnapshot.ProjectName);

            VerifyAll();
            queueNotifier1Mock.VerifyNoOtherCalls();
            queueNotifier2Mock.VerifyNoOtherCalls();
        }
        public void CancelPendingRequestRemovesPendingItems()
        {
            IProject project = (IProject)projectMock.MockInstance;

            IntegrationRequest request1 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);

            projectMock.Expect("NotifyPendingState");
            integrationQueue.Enqueue(new IntegrationQueueItem(project, request1, integrator));

            IntegrationRequest request2 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);

            projectMock.ExpectNoCall("NotifyPendingState");
            integrationQueue.Enqueue(new IntegrationQueueItem(project, request2, integrator));

            int queuedItemCount = integrationQueue.GetQueuedIntegrations().Length;

            Assert.AreEqual(2, queuedItemCount);
            integrationTriggerMock.Expect("IntegrationCompleted");

            integrator.CancelPendingRequest();

            queuedItemCount = integrationQueue.GetQueuedIntegrations().Length;
            Assert.AreEqual(1, queuedItemCount);

            VerifyAll();
        }
 private void AddToQueue(IntegrationRequest request)
 {
     integrationQueue.Enqueue(new IntegrationQueueItem(project, request, this));
 }
Example #9
0
        public void FirstProjectOnQueueShouldIntegrateImmediately()
        {
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueueUseFirst.Enqueue(integrationQueueItem1);

            string[] queueNames = integrationQueues.GetQueueNames();
            Assert.AreEqual(4, queueNames.Length);
            Assert.AreEqual(TestQueueName, queueNames[0]);

            IIntegrationQueueItem[] itemsOnQueue = integrationQueueUseFirst.GetQueuedIntegrations();
            Assert.AreEqual(1, itemsOnQueue.Length);
            Assert.AreSame(integrationQueueItem1, itemsOnQueue[0]);

            VerifyAll();
        }
        public void FirstProjectOnQueueShouldIntegrateImmediately()
        {
            queueNotifier1Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueueUseFirst.Enqueue(integrationQueueItem1);

            string[] queueNames = integrationQueues.GetQueueNames();
            Assert.AreEqual(4, queueNames.Length);
            Assert.AreEqual(TestQueueName, queueNames[0]);

            IIntegrationQueueItem[] itemsOnQueue = integrationQueueUseFirst.GetQueuedIntegrations();
            Assert.AreEqual(1, itemsOnQueue.Length);
            Assert.AreSame(integrationQueueItem1, itemsOnQueue[0]);

            VerifyAll();
            queueNotifier1Mock.VerifyNoOtherCalls();
        }
Example #11
0
        public void CancelPendingRequestRemovesPendingItems()
        {
            IProject project = (IProject)projectMock.Object;

            IntegrationRequest request1 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);

            projectMock.Setup(_project => _project.NotifyPendingState()).Verifiable();
            integrationQueue.Enqueue(new IntegrationQueueItem(project, request1, integrator));

            IntegrationRequest request2 = new IntegrationRequest(BuildCondition.IfModificationExists, "intervalTrigger", null);

            integrationQueue.Enqueue(new IntegrationQueueItem(project, request2, integrator));

            int queuedItemCount = integrationQueue.GetQueuedIntegrations().Length;

            Assert.AreEqual(2, queuedItemCount);
            integrationTriggerMock.Setup(_trigger => _trigger.IntegrationCompleted()).Verifiable();

            integrator.CancelPendingRequest();

            queuedItemCount = integrationQueue.GetQueuedIntegrations().Length;
            Assert.AreEqual(1, queuedItemCount);

            VerifyAll();
            projectMock.Verify(_project => _project.NotifyPendingState(), Times.Once);
        }