Пример #1
0
        private Beholder.Service.Processor.Implementation CreateSubject(Beholder.Service.Configuration configuration = null)
        {
            configuration ??= new Beholder.Service.Configuration();

            var options = A.Fake <IOptions <Beholder.Service.Configuration> >(builder => builder.ConfigureFake(fake => A.CallTo(() => fake.Value).Returns(configuration)));
            var logger  = A.Fake <ILogger <Beholder.Service.Processor.Implementation> >();

            return(new Beholder.Service.Processor.Implementation(options, logger));
        }
Пример #2
0
        public async Task OnlyPumpASingleMessageIfOneShotIsTrue()
        {
            Beholder.Service.Configuration configuration = new Beholder.Service.Configuration
            {
                OneShot = true
            };

            var subject = CreateSubject(configuration);

            var pipeline = A.Fake <Beholder.Service.IPipeline>();

            A.CallTo(() => pipeline.StartAsync(A <CancellationToken> .Ignored)).Returns(Task.CompletedTask);
            A.CallTo(() => pipeline.WaitForCompletion()).Returns(Task.CompletedTask);

            await Task.WhenAny(
                Task.Run(() => subject.RunAsync(pipeline, CancellationToken.None)),
                Task.Delay(TimeSpan.FromSeconds(1))
                );

            A.CallTo(() => pipeline.StartAsync(A <CancellationToken> .Ignored)).MustHaveHappenedOnceExactly();
        }
Пример #3
0
        private (Beholder.Service.Pipeline.IFunctions, Beholder.Service.Pipeline.Implementation) CreateSubject(Beholder.Service.Configuration configuration = null)
        {
            configuration ??= new Beholder.Service.Configuration();

            var options           = A.Fake <IOptions <Beholder.Service.Configuration> >(builder => builder.ConfigureFake(fake => A.CallTo(() => fake.Value).Returns(configuration)));
            var pipelineFunctions = A.Fake <Beholder.Service.Pipeline.IFunctions>();
            var logger            = A.Fake <ILogger <Beholder.Service.Pipeline.Implementation> >();
            var subject           = new Beholder.Service.Pipeline.Implementation(pipelineFunctions, options, logger);

            return(pipelineFunctions, subject);
        }
Пример #4
0
        private (Beholder.Service.Pipeline.IFactory, Beholder.Service.IProcessor, Beholder.Service.Implementation) CreateSubject(Beholder.Service.Configuration configuration = null)
        {
            var logger          = A.Fake <ILogger <Beholder.Service.Implementation> >();
            var pipelineFactory = A.Fake <Beholder.Service.Pipeline.IFactory>();
            var processor       = A.Fake <Beholder.Service.IProcessor>();
            var subject         = new Beholder.Service.Implementation(pipelineFactory, processor, logger);

            return(pipelineFactory, processor, subject);
        }