Ejemplo n.º 1
0
		public void Send(Event @event)
		{
		    Platform.CheckForNullReference(@event, "event");
			lock (_syncLock)
			{
				_queue.Enqueue(@event);
				Monitor.Pulse(_syncLock);
			}
		}
Ejemplo n.º 2
0
        public void TestBatchSending()
        {
            if (!BatchSendingSupported)
                Assert.Ignore("Broker does not appear to support batch sending");

            MockClientCallback client = new MockClientCallback();
            MockApplication app = new MockApplication(client);
            EventBroker broker = app.EventBroker;
            Thread.Sleep(WAIT_DELAY);

            broker.Suspended = true;
            Assert.IsTrue(broker.Suspended);
            client.Reset();

            Event[] events = new Event[50];
            for(int i=0; i<events.Length; i++)
            {
                events[i] = new MockEvent();
            }

            for (int i = 0; i < events.Length; i++)
            {
                broker.Send(events[i]);
            }

            Thread.Sleep(WAIT_DELAY);
            Assert.IsTrue(broker.Suspended, "Should remain suspsended after Send is called");
            Assert.IsTrue(client.EventCount == 0, "Should NOT send any message while it's being suspended");

            broker.Suspended = false;
            Assert.IsFalse(broker.Suspended);
            Thread.Sleep(WAIT_DELAY*5);
            Assert.IsTrue(client.EventCount == events.Length, "All messages should be sent after it's no longer suspended");
            
            const int MinBatchSizeRequired = 2;
            Assert.IsTrue(client.EventsSetSent.Count <= (events.Length/MinBatchSizeRequired), "Messages must be sent in batches");
        }
Ejemplo n.º 3
0
Archivo: Event.cs Proyecto: nhannd/Xian
 public bool Equals(Event other)
 {
     return other.Identifier == Identifier;
 }
 public void FireEvent(ClearCanvas.Web.Common.Event e)
 {
     _eventSent.Add(e);
 }