public void WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
		{
			DynamicMock mockSynchronizeInvoke = new DynamicMock(typeof (ISynchronizeInvoke));
			StubServerMonitor containedMonitor = new StubServerMonitor(@"tcp://blah/");

			SynchronizedServerMonitor monitor = new SynchronizedServerMonitor(
				containedMonitor,
				(ISynchronizeInvoke) mockSynchronizeInvoke.MockInstance);

			MonitorServerQueueChangedEventHandler delegateToQueueChanged = new MonitorServerQueueChangedEventHandler(Monitor_QueueChanged);
			monitor.QueueChanged += delegateToQueueChanged;

			mockSynchronizeInvoke.Expect("BeginInvoke", delegateToQueueChanged, new IsTypeOf(typeof (object[])));
			containedMonitor.OnQueueChanged(new MonitorServerQueueChangedEventArgs(null));

			mockSynchronizeInvoke.Verify();
		}
		public void QueueChangedIsFiredWheneverAnyContainedServerFiresIt()
		{
			queueChangedCount = 0;
			lastQueueChangedEventArgs = null;

			StubServerMonitor stubServerMonitor1 = new StubServerMonitor("tcp://somehost1/");
			StubServerMonitor stubServerMonitor2 = new StubServerMonitor("tcp://somehost2/");

			aggregator = new AggregatingServerMonitor(stubServerMonitor1, stubServerMonitor2);
			aggregator.QueueChanged += new MonitorServerQueueChangedEventHandler(Aggregator_QueueChanged);

			Assert.AreEqual(0, queueChangedCount);
			stubServerMonitor1.OnQueueChanged(new MonitorServerQueueChangedEventArgs(stubServerMonitor1));

			Assert.AreEqual(1, queueChangedCount);
			Assert.AreSame(stubServerMonitor1, lastQueueChangedEventArgs.ServerMonitor);
		}
Beispiel #3
0
        public void WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
        {
            DynamicMock       mockSynchronizeInvoke = new DynamicMock(typeof(ISynchronizeInvoke));
            StubServerMonitor containedMonitor      = new StubServerMonitor(@"tcp://blah/");

            SynchronizedServerMonitor monitor = new SynchronizedServerMonitor(
                containedMonitor,
                (ISynchronizeInvoke)mockSynchronizeInvoke.MockInstance);

            MonitorServerQueueChangedEventHandler delegateToQueueChanged = new MonitorServerQueueChangedEventHandler(Monitor_QueueChanged);

            monitor.QueueChanged += delegateToQueueChanged;

            mockSynchronizeInvoke.Expect("BeginInvoke", delegateToQueueChanged, new IsTypeOf(typeof(object[])));
            containedMonitor.OnQueueChanged(new MonitorServerQueueChangedEventArgs(null));

            mockSynchronizeInvoke.Verify();
        }
Beispiel #4
0
        public void WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
        {
            var mockSynchronizeInvoke          = new Mock <ISynchronizeInvoke>();
            StubServerMonitor containedMonitor = new StubServerMonitor(@"tcp://blah/");

            SynchronizedServerMonitor monitor = new SynchronizedServerMonitor(
                containedMonitor,
                (ISynchronizeInvoke)mockSynchronizeInvoke.Object);

            MonitorServerQueueChangedEventHandler delegateToQueueChanged = new MonitorServerQueueChangedEventHandler(Monitor_QueueChanged);

            monitor.QueueChanged += delegateToQueueChanged;

            mockSynchronizeInvoke.Setup(invoke => invoke.BeginInvoke(delegateToQueueChanged, It.IsAny <object[]>())).Verifiable();
            containedMonitor.OnQueueChanged(new MonitorServerQueueChangedEventArgs(null));

            mockSynchronizeInvoke.Verify();
        }
        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);
        }
		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);
		}