Esempio n. 1
0
        public override async Task When_a_scheduled_command_depends_on_an_event_that_never_arrives_it_is_eventually_abandoned()
        {
            // arrange
            var deliveryAttempts = 0;

            Configuration.Current.AddToCommandSchedulerPipeline <NonEventSourcedCommandTarget>(
                deliver: async(command, next) =>
            {
                deliveryAttempts++;
                await next(command);
            });

            var precondition = new EventHasBeenRecordedPrecondition(
                Guid.NewGuid().ToString().ToETag(),
                Guid.NewGuid());

            // act
            await Schedule(Any.CamelCaseName(),
                           new TestCommand(),
                           deliveryDependsOn : precondition);

            for (var i = 0; i < 10; i++)
            {
                await AdvanceClock(1.Days());
            }

            //assert
            deliveryAttempts.Should().Be(6);
        }
Esempio n. 2
0
        public override async Task When_an_immediately_scheduled_command_depends_on_a_precondition_that_has_not_been_met_yet_then_there_is_not_initially_an_attempt_recorded()
        {
            // arrange
            var targetId     = Any.CamelCaseName();
            var precondition = new EventHasBeenRecordedPrecondition(
                Guid.NewGuid().ToString().ToETag(),
                Guid.NewGuid());

            // act
            await Schedule(targetId,
                           new CreateCommandTarget(targetId),
                           deliveryDependsOn : precondition);

            // assert
            using (var db = CommandSchedulerDbContext())
            {
                var aggregateId = targetId.ToGuidV3();
                var command     = db.ScheduledCommands.Single(c => c.AggregateId == aggregateId);

                command.AppliedTime
                .Should()
                .NotHaveValue();

                command.Attempts
                .Should()
                .Be(0);
            }
        }
        public override async Task When_a_scheduled_command_depends_on_an_event_that_never_arrives_it_is_eventually_abandoned()
        {
            // arrange
            var deliveryAttempts = 0;
            Configuration.Current.AddToCommandSchedulerPipeline<CommandTarget>(
                deliver: async (command, next) =>
                {
                    deliveryAttempts++;
                    await next(command);
                });
         
            var precondition = new EventHasBeenRecordedPrecondition(
                Guid.NewGuid().ToString().ToETag(),
                Guid.NewGuid());

            // act
            await scheduler.Schedule(Any.CamelCaseName(),
                                     new TestCommand(),
                                     deliveryDependsOn: precondition);
         
            for (var i = 0; i < 10; i++)
            {
                  await AdvanceClock(1.Days());
            }

            //assert 
            deliveryAttempts.Should().Be(6);
        }
        public override async Task When_an_immediately_scheduled_command_depends_on_a_precondition_that_has_not_been_met_yet_then_there_is_not_initially_an_attempt_recorded()
        {
            // arrange
            var targetId = Any.CamelCaseName();
            var precondition = new EventHasBeenRecordedPrecondition(
                Guid.NewGuid().ToString().ToETag(),
                Guid.NewGuid());

            // act
            await scheduler.Schedule(targetId,
                                     new CreateCommandTarget(targetId),
                                     deliveryDependsOn: precondition);
        
            // assert
            using (var db = Configuration.Current.CommandSchedulerDbContext())
            {
                var aggregateId = targetId.ToGuidV3();
                var command = db.ScheduledCommands.Single(c => c.AggregateId == aggregateId);

                command.AppliedTime
                       .Should()
                       .NotHaveValue();

                command.Attempts
                       .Should()
                       .Be(0);
            }
        }