Пример #1
0
        public async Task <Option <ISavedImage> > Dequeue()
        {
            Option <ISavedImage> dequeueImage = await _imageQueue.Dequeue();

            dequeueImage.MatchSome(_ => _queueChanges.OnNext(new ImageQueueChangedEvent()));
            return(dequeueImage);
        }
Пример #2
0
        public void Dequeue_ImageWasDequeuedFromInnerQueue_ImageQueueChangesEventFired()
        {
            Option <ISavedImage> expectedDequeuedImage = A.Dummy <ISavedImage>().Some();

            A.CallTo(() => _innerQueue.Dequeue()).Returns(expectedDequeuedImage);

            Option <ISavedImage> dequeuedImage = Option.None <ISavedImage>();

            _testScheduler.ScheduleAsync(TimeSpan.FromTicks(5), async(s, t) =>
            {
                dequeuedImage = await _sut.Dequeue();
            });
            ITestableObserver <ImageQueueChangedEvent> imageQueueChanges = _testScheduler.Start(() => _sut.ImageQueueChanges, 0, 0, 100);

            imageQueueChanges.Messages.Should().HaveCount(1);
            dequeuedImage.HasValue.Should().BeTrue();
            dequeuedImage.Should().Be(expectedDequeuedImage);
        }