示例#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();
        }
示例#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();
        }
示例#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();
        }
示例#4
0
        public void BufferInvokesWhenNotBuffering()
        {
            var sut        = new EventBuffer();
            var bufferable = CreateImmediatelyInvokedEvent(1);

            sut.Buffer(bufferable.Object, 1);

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

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

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

            sut.StartBuffering();

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

            bufferable.Verify();
        }
示例#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();
        }