コード例 #1
0
        public async Task InitiateRuleRunForTwoWeeksButNullParamsDoesNotDoAnything()
        {
            A.CallTo(() => this.apiRepository.GetAsync()).Returns(new RuleParameterDto {
                HighProfits = null
            });

            var serialiser = new ScheduledExecutionMessageBusSerialiser(new ScheduleExecutionDtoMapper(null));
            var scheduler  = this.Build();

            var execution = new ScheduledExecution
            {
                Rules = new List <RuleIdentifier>
                {
                    new RuleIdentifier {
                        Rule = Rules.HighProfits, Ids = new string[0]
                    }
                },
                TimeSeriesInitiation  = new DateTime(2018, 01, 01),
                TimeSeriesTermination = new DateTime(2018, 01, 15)
            };

            var messageBody = serialiser.SerialiseScheduledExecution(execution);

            await scheduler.Disassemble(this.systemProcessOperationContext, execution, "any-id", messageBody);

            A.CallTo(() => this.distributedRulePublisher.ScheduleExecution(A <ScheduledExecution> .Ignored))
            .MustNotHaveHappened();
        }
コード例 #2
0
        public async Task InitiateRuleRunTwoRulesForOneYearJustRunsRuleWithTimeWindowOfThreeDaysSchedules22Runs()
        {
            A.CallTo(() => this.apiRepository.GetAsync()).Returns(
                new RuleParameterDto
            {
                HighProfits =
                    new[] { new HighProfitsRuleParameterDto {
                                WindowSize = new TimeSpan(3, 0, 0, 0, 0)
                            } },
                CancelledOrders = new[]
                {
                    new CancelledOrderRuleParameterDto
                    {
                        WindowSize = new TimeSpan(08, 0, 0, 0, 0)
                    }
                }
            });

            var serialiser = new ScheduledExecutionMessageBusSerialiser(new ScheduleExecutionDtoMapper(null));

            var scheduler = this.Build();

            var execution = new ScheduledExecution
            {
                Rules = new List <RuleIdentifier>
                {
                    new RuleIdentifier {
                        Rule = Rules.HighVolume, Ids = new string[0]
                    },
                    new RuleIdentifier
                    {
                        Rule = Rules.CancelledOrders, Ids = new string[0]
                    }
                },
                TimeSeriesInitiation  = new DateTime(2018, 01, 01),
                TimeSeriesTermination = new DateTime(2019, 01, 01)
            };

            var messageBody = serialiser.SerialiseScheduledExecution(execution);

            await scheduler.Disassemble(this.systemProcessOperationContext, execution, "any-id", messageBody);

            A.CallTo(() => this.apiRepository.GetAsync()).MustHaveHappenedOnceExactly();
            A.CallTo(() => this.distributedRulePublisher.ScheduleExecution(A <ScheduledExecution> .Ignored))
            .MustHaveHappenedANumberOfTimesMatching(i => i == 74);
        }
コード例 #3
0
        public async Task InitiateRuleRunForEightDaysJustRunsRuleWithTimeWindowOf10Days()
        {
            A.CallTo(() => this.apiRepository.GetAsync()).Returns(
                new RuleParameterDto
            {
                HighVolumes = new[]
                {
                    new HighVolumeRuleParameterDto
                    {
                        Id = "abc", WindowSize = new TimeSpan(10, 0, 0, 0, 0)
                    }
                }
            });

            var serialiser = new ScheduledExecutionMessageBusSerialiser(new ScheduleExecutionDtoMapper(null));
            var scheduler  = this.Build();

            var execution = new ScheduledExecution
            {
                Rules = new List <RuleIdentifier>
                {
                    new RuleIdentifier {
                        Rule = Rules.HighVolume, Ids = new string[0]
                    }
                },
                TimeSeriesInitiation  = new DateTime(2018, 01, 01),
                TimeSeriesTermination = new DateTime(2018, 01, 10)
            };

            var messageBody = serialiser.SerialiseScheduledExecution(execution);

            await scheduler.Disassemble(this.systemProcessOperationContext, execution, "any-id", messageBody);

            A.CallTo(() => this.apiRepository.GetAsync()).MustHaveHappenedOnceExactly();
            A.CallTo(() => this.distributedRulePublisher.ScheduleExecution(A <ScheduledExecution> .Ignored))
            .MustHaveHappenedOnceExactly();
        }