示例#1
0
        public async Task ResolveCommandPipelineWithBehaviour(int booId)
        {
            var emitter = _serviceCollection
                          .AddSingleton(typeof(ICommandBehaviour <>), typeof(MeasureBehaviour <>))
                          .AddCommandProcessor <BoosCreate.Processor>()
                          .BuildServiceProvider()
                          .GetRequiredService <IEmitter>();

            var command = new BoosCreate.Command {
                Id = booId
            };
            await emitter.Execute(command);

            command.Measured.Should().BeTrue();

            _repository.Verify(repository => repository
                               .AddElement(It.Is <Boo>(b => b.Id == booId)));
        }
示例#2
0
        public async Task ResolveCommandFullPipeline(int booId)
        {
            var emitter = _serviceCollection
                          .AddCommandBehaviour <MeasureBehaviour <BoosCreate.Command> >()
                          .AddCommandProcessor <BoosCreate.PreProcessor>()
                          .AddCommandProcessor <BoosCreate.Processor>()
                          .AddCommandProcessor <BoosCreate.PostProcessor>(ServiceLifetime.Scoped)
                          .BuildServiceProvider()
                          .GetRequiredService <IEmitter>();

            var command = new BoosCreate.Command {
                Id = booId
            };
            await emitter.Execute(command);

            command.Measured.Should().BeTrue();
            command.PreProcessed.Should().BeTrue();
            command.PostProcessed.Should().BeTrue();

            _repository.Verify(repository => repository
                               .AddElement(It.Is <Boo>(b => b.Id == booId)));
        }