コード例 #1
0
        public void WhenAnEventIsEnqueuedItIsWrittenToABatch_FlushWhileRunning()
        {
            var bs  = new InMemoryBatchedSink(TinyWait + TinyWait);
            var pbs = new PeriodicBatchingSink(bs, new PeriodicBatchingSinkOptions {
                BatchSizeLimit = 2, Period = MicroWait, EagerlyEmitFirstEvent = true
            });
            var evt = Some.InformationEvent();

            pbs.Emit(evt);
            Thread.Sleep(TinyWait);
            pbs.Dispose();
            Assert.Equal(1, bs.Batches.Count);
            Assert.True(bs.IsDisposed);
            Assert.False(bs.WasCalledAfterDisposal);
        }
コード例 #2
0
        public void WhenAnEventIsEnqueuedItIsWrittenToABatch_OnFlush()
        {
            var bs  = new InMemoryBatchedSink(TimeSpan.Zero);
            var pbs = new PeriodicBatchingSink(bs, new PeriodicBatchingSinkOptions
            {
                BatchSizeLimit = 2, Period = TinyWait, EagerlyEmitFirstEvent = true
            });
            var evt = Some.InformationEvent();

            pbs.Emit(evt);
            pbs.Dispose();
            Assert.Equal(1, bs.Batches.Count);
            Assert.Equal(1, bs.Batches[0].Count);
            Assert.Same(evt, bs.Batches[0][0]);
            Assert.True(bs.IsDisposed);
            Assert.False(bs.WasCalledAfterDisposal);
        }