Пример #1
0
        public void BeCompletedAfterCompletion()
        {
            var denoiser = new DenoisingStream(strategy.Object, new Counter(), CancellationToken.None, logger.Object);

            denoiser.Complete();

            Assert.True(denoiser.Completed);
        }
Пример #2
0
        public async Task CompleteStreamWhenRequested()
        {
            var denoiser = new DenoisingStream(strategy.Object, new Counter(), CancellationToken.None, logger.Object);
            var observer = new TestImageObserver <Rgb>();

            using (denoiser.Subscribe(observer))
            {
                denoiser.Complete();
                await Task.Delay(TimeSpan.FromMilliseconds(100));
            }

            Assert.True(observer.StreamCompleted);
        }
Пример #3
0
        public async Task NotProvideDataForObserversAfterCompletion()
        {
            var inputImage    = new Image <Rgb, byte>(1, 1);
            var expectedImage = new Image <Rgb, byte>(10, 10);

            strategy.Setup(s => s.Denoise(inputImage)).Returns(expectedImage);

            var denoiser = new DenoisingStream(strategy.Object, new Counter(), CancellationToken.None, logger.Object);
            var observer = new TestImageObserver <Rgb>();

            using (denoiser.Subscribe(observer))
            {
                denoiser.Complete();
                denoiser.Process(inputImage);
                await Task.Delay(TimeSpan.FromMilliseconds(100));
            }

            Assert.Empty(observer.ReceivedItems);
        }