示例#1
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();
        }
示例#2
0
        public void GetIntegrationQueueSnapshotForMultipleProjectsOnSingleQueue()
        {
            project1Mock.SetupGet(project => project.CurrentActivity).Returns(ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueue1.Enqueue(integrationQueueItem1);

            // Second item is different project but same queue
            project2Mock.SetupGet(project => project.QueueName).Returns(TestQueueName);
            project2Mock.SetupGet(project => project.CurrentActivity).Returns(ProjectActivity.Pending);
            queueNotifier2Mock.Setup(notifier => notifier.NotifyEnteringIntegrationQueue()).Verifiable();
            integrationQueue1.Enqueue(integrationQueueItem2);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

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

            QueueSnapshot queueSnapshot = queueSetSnapshot.Queues[0];

            Assert.AreEqual(2, queueSnapshot.Requests.Count);

            QueuedRequestSnapshot firstQueuedRequestSnapshot = queueSnapshot.Requests[0];

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

            QueuedRequestSnapshot secondQueuedRequestSnapshot = queueSnapshot.Requests[1];

            Assert.AreEqual("ProjectTwo", secondQueuedRequestSnapshot.ProjectName);
            Assert.AreEqual(ProjectActivity.Pending, secondQueuedRequestSnapshot.Activity);

            VerifyAll();
            queueNotifier1Mock.VerifyNoOtherCalls();
            queueNotifier2Mock.VerifyNoOtherCalls();
        }
        public void ActivityGetSetTest()
        {
            QueuedRequestSnapshot activity = new QueuedRequestSnapshot();

            activity.Activity = ProjectActivity.Building;
            Assert.AreEqual(ProjectActivity.Building, activity.Activity);
        }
 private static void WriteQueuedRequestSnapshot(XmlWriter xmlWriter, QueuedRequestSnapshot queuedRequest)
 {
     xmlWriter.WriteStartElement("Request");
     xmlWriter.WriteAttributeString("projectName", queuedRequest.ProjectName);
     xmlWriter.WriteAttributeString("activity", queuedRequest.Activity.ToString());
     xmlWriter.WriteEndElement();
 }
        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();
        }
示例#6
0
        /// <summary>
        /// Updates the details on a build queue.
        /// </summary>
        /// <param name="value">The new build queue details.</param>
        public void Update(QueuedRequestSnapshot value)
        {
            // Validate the arguments
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            // Find all the changed properties
            var changes = new List <string>();

            if (snapshot.Activity != value.Activity)
            {
                changes.Add("Activity");
            }
            if (snapshot.RequestTime != value.RequestTime)
            {
                changes.Add("RequestTime");
            }

            // Make the actual change
            snapshot = value;

            // Fire any change notifications
            foreach (var change in changes)
            {
                FirePropertyChanged(change);
            }
        }
        public void GetIntegrationQueueSnapshotForMultipleProjectsOnSingleQueue()
        {
            project1Mock.SetupResult("CurrentActivity", ProjectActivity.CheckingModifications);
            queueNotifier1Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier1Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue1.Enqueue(integrationQueueItem1);

            // Second item is different project but same queue
            project2Mock.ExpectAndReturn("QueueName", TestQueueName);
            project2Mock.SetupResult("CurrentActivity", ProjectActivity.Pending);
            queueNotifier2Mock.Expect("NotifyEnteringIntegrationQueue");
            queueNotifier2Mock.ExpectNoCall("NotifyExitingIntegrationQueue", typeof(bool));
            integrationQueue1.Enqueue(integrationQueueItem2);

            QueueSetSnapshot queueSetSnapshot = integrationQueues.GetIntegrationQueueSnapshot();

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

            QueueSnapshot queueSnapshot = queueSetSnapshot.Queues[0];

            Assert.AreEqual(2, queueSnapshot.Requests.Count);

            QueuedRequestSnapshot firstQueuedRequestSnapshot = queueSnapshot.Requests[0];

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

            QueuedRequestSnapshot secondQueuedRequestSnapshot = queueSnapshot.Requests[1];

            Assert.AreEqual("ProjectTwo", secondQueuedRequestSnapshot.ProjectName);
            Assert.AreEqual(ProjectActivity.Pending, secondQueuedRequestSnapshot.Activity);

            VerifyAll();
        }
        public void ProjectNameGetSetTest()
        {
            QueuedRequestSnapshot activity = new QueuedRequestSnapshot();

            activity.ProjectName = "testing";
            Assert.AreEqual("testing", activity.ProjectName);
        }
示例#9
0
 /// <summary>
 /// Cancels a pending request request.
 /// </summary>
 /// <param name="request">The request.</param>
 public void CancelRequest(QueuedRequestSnapshot request)
 {
     if (request.Activity.IsPending())
     {
         this.client.CancelPendingRequest(request.ProjectName);
     }
 }
        public void LastBuildDateGetSetTest()
        {
            DateTime timeNow = DateTime.Now;
            QueuedRequestSnapshot activity = new QueuedRequestSnapshot();

            activity.RequestTime = timeNow;
            Assert.AreEqual(timeNow, activity.RequestTime);
        }
示例#11
0
 public IntegrationQueueTreeNodeTag(IntegrationQueueTreeNodeAdaptor adaptor, QueueSnapshot queueSnapshot,
                                    QueuedRequestSnapshot queuedRequestSnapshot, int queueIndex)
 {
     this.Adaptor               = adaptor;
     this.QueueSnapshot         = queueSnapshot;
     this.QueuedRequestSnapshot = queuedRequestSnapshot;
     this.QueueIndex            = queueIndex;
 }
        private void DisplayIntegrationQueueInTreeViewNode()
        {
            serverTreeNode.Nodes.Clear();

            CruiseServerSnapshot cruiseServerSnapshot = serverMonitor.CruiseServerSnapshot;

            if (cruiseServerSnapshot == null)
            {
                return;
            }

            QueueSetSnapshot queueSetSnapshot = serverMonitor.CruiseServerSnapshot.QueueSetSnapshot;

            if (queueSetSnapshot != null && queueSetSnapshot.Queues != null && queueSetSnapshot.Queues.Count > 0)
            {
                foreach (QueueSnapshot queue in queueSetSnapshot.Queues)
                {
                    string queueNodeTitle  = queue.QueueName;
                    int    queueImageIndex = IntegrationQueueNodeType.QueueEmpty.ImageIndex;
                    if (!queue.IsEmpty)
                    {
                        queueNodeTitle  = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} ({1})", queue.QueueName, queue.Requests.Count);
                        queueImageIndex = IntegrationQueueNodeType.QueuePopulated.ImageIndex;
                    }
                    TreeNode queueNode = new TreeNode(queueNodeTitle, queueImageIndex, queueImageIndex);
                    queueNode.Tag = new IntegrationQueueTreeNodeTag(this, queue);
                    serverTreeNode.Nodes.Add(queueNode);

                    for (int index = 0; index < queue.Requests.Count; index++)
                    {
                        QueuedRequestSnapshot queuedRequest = queue.Requests[index];
                        TreeNode queuedItemNode             = new TreeNode(queuedRequest.ProjectName);
                        queuedItemNode.Tag = new IntegrationQueueTreeNodeTag(this, queue, queuedRequest, index);

                        int requestImageIndex = IntegrationQueueNodeType.PendingInQueue.ImageIndex;
                        if (queuedRequest.Activity == ProjectActivity.CheckingModifications)
                        {
                            requestImageIndex = IntegrationQueueNodeType.CheckingModifications.ImageIndex;
                        }
                        else if (queuedRequest.Activity == ProjectActivity.Building)
                        {
                            requestImageIndex = IntegrationQueueNodeType.Building.ImageIndex;
                        }

                        queuedItemNode.ImageIndex = queuedItemNode.SelectedImageIndex = requestImageIndex;
                        queueNode.Nodes.Add(queuedItemNode);
                    }
                }
            }

            serverTreeNode.Expand();
            QueueTreeView queueTreeView = serverTreeNode.TreeView as QueueTreeView;

            if (queueTreeView != null)
            {
                queueTreeView.RestoreExpandedNodes(serverTreeNode);
            }
        }
        private CruiseServerSnapshot CreatePopulatedQueuesSnapshot()
        {
            CruiseServerSnapshot cruiseServerSnapshot = CreateEmptyQueuesSnapshot();
            QueueSetSnapshot     queueSetSnapshot     = cruiseServerSnapshot.QueueSetSnapshot;

            QueueSnapshot queueSnapshot1 = queueSetSnapshot.Queues[0];

            QueuedRequestSnapshot queuedRequestSnapshot1 = new QueuedRequestSnapshot("Project1", ProjectActivity.CheckingModifications);

            queueSnapshot1.Requests.Add(queuedRequestSnapshot1);

            QueuedRequestSnapshot queuedRequestSnapshot2 = new QueuedRequestSnapshot("Project2", ProjectActivity.Pending);

            queueSnapshot1.Requests.Add(queuedRequestSnapshot2);

            return(cruiseServerSnapshot);
        }
示例#14
0
        /// <summary>
        /// Initialise a new build queue request.
        /// </summary>
        /// <param name="client">The underlying client.</param>
        /// <param name="buildQueue">The queue this project belongs to.</param>
        /// <param name="snapshot">The actual build queue request details.</param>
        public BuildQueueRequest(CruiseServerClientBase client, BuildQueue buildQueue, QueuedRequestSnapshot snapshot)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (buildQueue == null)
            {
                throw new ArgumentNullException("buildQueue");
            }
            if (snapshot == null)
            {
                throw new ArgumentNullException("snapshot");
            }

            this.client     = client;
            this.buildQueue = buildQueue;
            this.snapshot   = snapshot;
        }
示例#15
0
        private static QueueSnapshot BuildQueueSnapshot(IIntegrationQueue queue)
        {
            QueueSnapshot queueSnapshot = new QueueSnapshot(queue.Name);

            for (int index = 0; index < queue.Count; index++)
            {
                IIntegrationQueueItem integrationQueueItem = (IIntegrationQueueItem)queue[index];
                // The first request in the queue shows it's real activity of CheckingModifications or Building
                // Everything else is in a pending state.
                ProjectActivity projectActivity = ProjectActivity.Pending;
                if (index == 0)
                {
                    projectActivity = integrationQueueItem.Project.CurrentActivity;
                }
                QueuedRequestSnapshot queuedRequestSnapshot = new QueuedRequestSnapshot(
                    integrationQueueItem.Project.Name,
                    projectActivity,
                    integrationQueueItem.IntegrationRequest.RequestTime);
                queueSnapshot.Requests.Add(queuedRequestSnapshot);
            }
            return(queueSnapshot);
        }
        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();
        }
示例#17
0
        private QueueSetSnapshot ConvertDashboardQueues(DashboardQueue[] dashboardQueues)
        {
            QueueSetSnapshot queueSetSnapshot = new QueueSetSnapshot();

            if (dashboardQueues != null)
            {
                foreach (DashboardQueue dashboardQueue in dashboardQueues)
                {
                    QueueSnapshot queueSnapshot = new QueueSnapshot(dashboardQueue.Name);
                    if (dashboardQueue.Requests != null)
                    {
                        foreach (DashboardQueuedRequest dashboardQueuedRequest in dashboardQueue.Requests)
                        {
                            QueuedRequestSnapshot queuedRequestSnapshot = new QueuedRequestSnapshot(
                                dashboardQueuedRequest.ProjectName,
                                new ProjectActivity(dashboardQueuedRequest.Activity));
                            queueSnapshot.Requests.Add(queuedRequestSnapshot);
                        }
                    }
                    queueSetSnapshot.Queues.Add(queueSnapshot);
                }
            }
            return(queueSetSnapshot);
        }