예제 #1
0
        private void TestActivityMonitorSubscriptions(IWorkItemActivityMonitor monitor, IWorkItemActivityCallback callback)
        {
            ResetCallbackFields();

            var item = new WorkItemData {
                Type = DicomRetrieveRequest.WorkItemTypeString
            };
            var items = new List <WorkItemData> {
                item
            };
            var eventType = WorkItemsChangedEventType.Update;

            SubscribeAndPause(monitor, WorkItemChanged1);

            WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 1);
            Assert.AreEqual(1, WorkItemChanged1Count);
            Assert.AreEqual(0, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            SubscribeAndPause(monitor, WorkItemChanged2);
            WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2);
            Assert.AreEqual(2, WorkItemChanged1Count);
            Assert.AreEqual(1, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            item.Type = DicomSendRequest.WorkItemTypeString;
            callback.WorkItemsChanged(eventType, items);
            Thread.Sleep(100);
            Assert.AreEqual(3, WorkItemChanged1Count);
            Assert.AreEqual(2, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            UnsubscribeAndPause(monitor, WorkItemChanged1);
            callback.WorkItemsChanged(eventType, items);
            Thread.Sleep(100);
            Assert.AreEqual(3, WorkItemChanged1Count);
            Assert.AreEqual(3, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            SubscribeAndPause(monitor, WorkItemChanged1);
            UnsubscribeAndPause(monitor, WorkItemChanged2);
            SubscribeAndPause(monitor, WorkItemChanged3);
            WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2);
            Assert.AreEqual(4, WorkItemChanged1Count);
            Assert.AreEqual(3, WorkItemChanged2Count);
            Assert.AreEqual(1, WorkItemChanged3Count);

            //TODO (Marmot): Expand to include multiple filters, etc.
        }
예제 #2
0
 void IWorkItemActivityCallback.WorkItemsChanged(WorkItemsChangedEventType eventType, List <WorkItemData> workItems)
 {
     if (_isSubscribed)
     {
         Callback.WorkItemsChanged(eventType, workItems);
     }
 }
예제 #3
0
        private void TestActivityMonitorSubscriptions(IWorkItemActivityMonitor monitor, IWorkItemActivityCallback callback)
        {
            ResetCallbackFields();

            var item = new WorkItemData { Type = DicomRetrieveRequest.WorkItemTypeString };
			var items = new List<WorkItemData> { item };
        	var eventType = WorkItemsChangedEventType.Update;
			SubscribeAndPause(monitor, WorkItemChanged1);

			WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 1);
            Assert.AreEqual(1, WorkItemChanged1Count);
            Assert.AreEqual(0, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            SubscribeAndPause(monitor, WorkItemChanged2);
			WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2);
            Assert.AreEqual(2, WorkItemChanged1Count);
            Assert.AreEqual(1, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            item.Type = DicomSendRequest.WorkItemTypeString;
			callback.WorkItemsChanged(eventType, items);
            Thread.Sleep(100);
            Assert.AreEqual(3, WorkItemChanged1Count);
            Assert.AreEqual(2, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            UnsubscribeAndPause(monitor, WorkItemChanged1);
			callback.WorkItemsChanged(eventType, items);
            Thread.Sleep(100);
            Assert.AreEqual(3, WorkItemChanged1Count);
            Assert.AreEqual(3, WorkItemChanged2Count);
            Assert.AreEqual(0, WorkItemChanged3Count);

            SubscribeAndPause(monitor, WorkItemChanged1);
            UnsubscribeAndPause(monitor, WorkItemChanged2);
            SubscribeAndPause(monitor, WorkItemChanged3);
			WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2);
            Assert.AreEqual(4, WorkItemChanged1Count);
            Assert.AreEqual(3, WorkItemChanged2Count);
            Assert.AreEqual(1, WorkItemChanged3Count);

            //TODO (Marmot): Expand to include multiple filters, etc.
        }