public void CanCreateListViewItem()
        {
            StubServerMonitor serverMonitor = new StubServerMonitor(ServerUrl);

            IntegrationQueueTreeNodeAdaptor adaptor = new IntegrationQueueTreeNodeAdaptor(serverMonitor);
            TreeNode item = adaptor.Create();

            Assert.AreEqual("blah:1000", item.Text);
            Assert.AreEqual(IntegrationQueueNodeType.RemotingServer.ImageIndex, item.ImageIndex);
        }
        public void CreateJustServerNodeWhenNoChildQueues()
        {
            StubServerMonitor serverMonitor = new StubServerMonitor(ServerUrl);

            serverMonitor.CruiseServerSnapshot = CreateNoQueuesSnapshot();

            IntegrationQueueTreeNodeAdaptor adaptor = new IntegrationQueueTreeNodeAdaptor(serverMonitor);
            TreeNode item = adaptor.Create();

            Assert.AreEqual(0, item.Nodes.Count);
        }
        public void WhenTheStateOfTheQueueChangesTheChildNodesOfTheServerNodeAreUpdated()
        {
            StubServerMonitor serverMonitor = new StubServerMonitor(ServerUrl);

            serverMonitor.CruiseServerSnapshot = CreateEmptyQueuesSnapshot();

            IntegrationQueueTreeNodeAdaptor adaptor = new IntegrationQueueTreeNodeAdaptor(serverMonitor);
            TreeNode item = adaptor.Create();

            Assert.AreEqual(2, item.Nodes.Count);
            TreeNode firstQueueNode  = item.Nodes[0];
            TreeNode secondQueueNode = item.Nodes[1];

            Assert.AreEqual("Queue1", firstQueueNode.Text);
            Assert.AreEqual("Queue2", secondQueueNode.Text);

            Assert.AreEqual(0, firstQueueNode.Nodes.Count);
            Assert.AreEqual(0, secondQueueNode.Nodes.Count);
            Assert.AreEqual(IntegrationQueueNodeType.QueueEmpty.ImageIndex, firstQueueNode.ImageIndex);

            // Now lets add something to a queue.
            serverMonitor.CruiseServerSnapshot = CreatePopulatedQueuesSnapshot();

            serverMonitor.OnQueueChanged(new MonitorServerQueueChangedEventArgs(serverMonitor));

            firstQueueNode  = item.Nodes[0];
            secondQueueNode = item.Nodes[1];
            Assert.AreEqual(2, firstQueueNode.Nodes.Count);
            Assert.AreEqual(0, secondQueueNode.Nodes.Count);

            TreeNode firstQueuedItemNode  = firstQueueNode.Nodes[0];
            TreeNode secondQueuedItemNode = firstQueueNode.Nodes[1];

            Assert.AreEqual(IntegrationQueueNodeType.QueuePopulated.ImageIndex, firstQueueNode.ImageIndex);
            Assert.AreEqual(IntegrationQueueNodeType.CheckingModifications.ImageIndex, firstQueuedItemNode.ImageIndex);
            Assert.AreEqual(IntegrationQueueNodeType.PendingInQueue.ImageIndex, secondQueuedItemNode.ImageIndex);
        }