예제 #1
0
        public void Dequeue_with_events_traces_event_on_error()
        {
            InputQueueStub <string> inner       = new InputQueueStub <string>();
            QueueEventSource        eventSource = QueueEventSource.Instance;
            Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            InputQueueWithEvents <string> queue = new InputQueueWithEvents <string>(inner, id, eventSource);

            using (QueueEventListener listener = new QueueEventListener(eventSource, EventLevel.Informational, EventKeywords.None))
            {
                Task <string> task = queue.DequeueAsync();

                Assert.False(task.IsCompleted);

                listener.VerifyEvent(QueueEventId.Dequeue, EventLevel.Informational, EventKeywords.None, id);
                listener.Events.Clear();

                InvalidTimeZoneException expectedException = new InvalidTimeZoneException("Expected.");
                inner.PendingDequeue.SetException(expectedException);

                Assert.Equal(TaskStatus.Faulted, task.Status);
                Assert.NotNull(task.Exception);
                AggregateException ae = task.Exception;
                Assert.Equal(1, ae.InnerExceptions.Count);
                Assert.Same(expectedException, ae.InnerExceptions[0]);

                listener.VerifyEvent(QueueEventId.DequeueCompleted, EventLevel.Informational, EventKeywords.None, id);
            }
        }
예제 #2
0
        public void Dispose_with_events_traces_event()
        {
            InputQueueStub <string> inner       = new InputQueueStub <string>();
            QueueEventSource        eventSource = QueueEventSource.Instance;
            Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            InputQueueWithEvents <string> queue = new InputQueueWithEvents <string>(inner, id, eventSource);

            using (QueueEventListener listener = new QueueEventListener(eventSource, EventLevel.Informational, EventKeywords.None))
            {
                queue.Dispose();

                Assert.True(inner.Disposed);
                listener.VerifyEvent(QueueEventId.QueueDispose, EventLevel.Informational, EventKeywords.None, id);
            }
        }
예제 #3
0
        public void Enqueue_with_events_traces_event()
        {
            InputQueueStub <string> inner       = new InputQueueStub <string>();
            QueueEventSource        eventSource = QueueEventSource.Instance;
            Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            InputQueueWithEvents <string> queue = new InputQueueWithEvents <string>(inner, id, eventSource);

            using (QueueEventListener listener = new QueueEventListener(eventSource, EventLevel.Informational, EventKeywords.None))
            {
                inner.Enqueued += delegate(object sender, EventArgs e)
                {
                    listener.VerifyEvent(QueueEventId.Enqueue, EventLevel.Informational, EventKeywords.None, id);
                    listener.Events.Clear();
                };

                queue.Enqueue("a");

                Assert.Equal("a", inner.Item);
                listener.VerifyEvent(QueueEventId.EnqueueCompleted, EventLevel.Informational, EventKeywords.None, id);
            }
        }
예제 #4
0
        public void Dequeue_with_events_traces_event()
        {
            InputQueueStub <string> inner       = new InputQueueStub <string>();
            QueueEventSource        eventSource = QueueEventSource.Instance;
            Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            InputQueueWithEvents <string> queue = new InputQueueWithEvents <string>(inner, id, eventSource);

            using (QueueEventListener listener = new QueueEventListener(eventSource, EventLevel.Informational, EventKeywords.None))
            {
                Task <string> task = queue.DequeueAsync();

                Assert.False(task.IsCompleted);

                listener.VerifyEvent(QueueEventId.Dequeue, EventLevel.Informational, EventKeywords.None, id);
                listener.Events.Clear();

                inner.PendingDequeue.SetResult("a");

                Assert.Equal(TaskStatus.RanToCompletion, task.Status);
                Assert.Equal("a", task.Result);
                listener.VerifyEvent(QueueEventId.DequeueCompleted, EventLevel.Informational, EventKeywords.None, id);
            }
        }
예제 #5
0
        public void Enqueue_with_events_traces_event_on_error()
        {
            InputQueueStub <string> inner       = new InputQueueStub <string>();
            QueueEventSource        eventSource = QueueEventSource.Instance;
            Guid id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            InputQueueWithEvents <string> queue = new InputQueueWithEvents <string>(inner, id, eventSource);

            using (QueueEventListener listener = new QueueEventListener(eventSource, EventLevel.Informational, EventKeywords.None))
            {
                InvalidProgramException expectedException = new InvalidProgramException("Expected.");
                inner.Enqueued += delegate(object sender, EventArgs e)
                {
                    listener.VerifyEvent(QueueEventId.Enqueue, EventLevel.Informational, EventKeywords.None, id);
                    listener.Events.Clear();
                    throw expectedException;
                };

                InvalidProgramException ipe = Assert.Throws <InvalidProgramException>(() => queue.Enqueue("a"));
                Assert.Same(expectedException, ipe);

                listener.VerifyEvent(QueueEventId.EnqueueCompleted, EventLevel.Informational, EventKeywords.None, id);
            }
        }
예제 #6
0
 public QueueEventListener(QueueEventSource eventSource, EventLevel level, EventKeywords keywords)
 {
     this.Events      = new List <EventWrittenEventArgs>();
     this.eventSource = eventSource;
     this.EnableEvents(this.eventSource, level, keywords);
 }
예제 #7
0
 public QueueEventListener(QueueEventSource eventSource, EventLevel level, EventKeywords keywords)
 {
     this.Events = new List<EventWrittenEventArgs>();
     this.eventSource = eventSource;
     this.EnableEvents(this.eventSource, level, keywords);
 }