protected override void Given()
        {
            this.collectErrorsListener = new MockEventListener();
            this.collectErrorsListener.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.Informational, SemanticLoggingEventSource.Keywords.Sink);

            this.sink = new TestableWindowsAzureTableSink("TestName", maxBufferSize: BufferSize);
            sink.WaitHandle.Reset();
        }
        public void when_sending_on_completed_blocks_for_timeout_period_only()
        {
            var timeout = TimeSpan.FromSeconds(1.75);
            var delta   = TimeSpan.FromSeconds(.5);

            using (var sink = new TestableWindowsAzureTableSink("TestName", onCompletedTimeout: timeout))
            {
                sink.WaitHandle.Reset();

                sink.OnNext(new CloudEventEntry(EventEntryTestHelper.Create(eventId: 10)));

                var stopWatch = Stopwatch.StartNew();
                sink.OnCompleted();
                stopWatch.Stop();

                Assert.IsTrue(stopWatch.Elapsed >= timeout - delta, "Elapsed: {0}. Expected at least {1}", stopWatch.Elapsed, timeout - delta);
                Assert.IsTrue(stopWatch.Elapsed <= timeout + delta, "Elapsed: {0}. Expected at most {1}", stopWatch.Elapsed, timeout + delta);

                sink.WaitHandle.Set();
            }
        }