Example #1
0
        public void FlushMergesCallsWithSameSender()
        {
            var sut        = new EventBuffer();
            var bufferable = CreateBufferInvokedEvent(1, 2);

            sut.StartBuffering();

            sut.Buffer(bufferable.Object, 1);
            sut.Buffer(bufferable.Object, 2);
            sut.Flush();

            bufferable.Verify();
        }
Example #2
0
        public void FlushKeepsCallsWithDifferentSender()
        {
            var sut         = new EventBuffer();
            var bufferable1 = CreateBufferInvokedEvent(1);
            var bufferable2 = CreateBufferInvokedEvent(2);

            sut.StartBuffering();

            sut.Buffer(bufferable1.Object, 1);
            sut.Buffer(bufferable2.Object, 2);
            sut.Flush();

            bufferable1.Verify();
            bufferable2.Verify();
        }
Example #3
0
        public void FlushLoopsOverBuffers()
        {
            var sut         = new EventBuffer();
            var bufferable1 = CreateBufferInvokedEvent(1);
            var bufferable2 = CreateBufferInvokedEvent(2);

            bufferable1.Setup(b => b.Invoke(It.IsAny <List <int> >()))
            .Callback(() => sut.Buffer(bufferable2.Object, 2));
            sut.StartBuffering();

            sut.Buffer(bufferable1.Object, 1);
            sut.Flush();

            bufferable1.Verify();
            bufferable2.Verify();
        }
Example #4
0
        public void BufferInvokesWhenNotBuffering()
        {
            var sut        = new EventBuffer();
            var bufferable = CreateImmediatelyInvokedEvent(1);

            sut.Buffer(bufferable.Object, 1);

            bufferable.Verify();
        }
Example #5
0
        public void BufferDoesNotInvokeWhenBuffering()
        {
            var sut        = new EventBuffer();
            var bufferable = new Mock <IBufferableEvent <int> >();

            sut.StartBuffering();
            sut.Buffer(bufferable.Object, 1);

            bufferable.VerifyNoOtherCalls();
        }
Example #6
0
        public void FlushInvokesBufferedCall()
        {
            var sut        = new EventBuffer();
            var bufferable = CreateBufferInvokedEvent(1);

            sut.StartBuffering();

            sut.Buffer(bufferable.Object, 1);
            sut.Flush();

            bufferable.Verify();
        }
Example #7
0
        public void FlushClearsBuffer()
        {
            var sut        = new EventBuffer();
            var bufferable = new Mock <IBufferableEvent <int> >();

            sut.StartBuffering();
            sut.Buffer(bufferable.Object, 1);
            sut.Flush();
            bufferable.Reset();

            sut.Flush();

            bufferable.VerifyNoOtherCalls();
        }