public ISystemProcessOperationRunRuleContext CreateAndStartRuleRunContext(
            string ruleDescription,
            string ruleVersion,
            string ruleParameterId,
            int ruleTypeId,
            bool isBackTest,
            DateTime ruleScheduleBegin,
            DateTime ruleScheduleEnd,
            string correlationId,
            bool ruleRunMode)
        {
            var ctx        = this._runRuleContextFactory.Build(this);
            var startEvent = new SystemProcessOperationRuleRun
            {
                SystemProcessId          = this._systemProcessOperation.SystemProcessId,
                SystemProcessOperationId = this._systemProcessOperation.Id,
                RuleDescription          = ruleDescription,
                RuleVersion       = ruleVersion,
                RuleParameterId   = ruleParameterId,
                ScheduleRuleStart = ruleScheduleBegin,
                ScheduleRuleEnd   = ruleScheduleEnd,
                CorrelationId     = correlationId,
                IsBackTest        = isBackTest,
                RuleTypeId        = ruleTypeId,
                IsForceRun        = ruleRunMode
            };

            ctx.StartEvent(startEvent);

            return(ctx);
        }
        public async Task Get_RuleRun_UpdatesInDb()
        {
            var connFactory         = new ConnectionStringFactory(this._config);
            var processRepository   = new SystemProcessRepository(connFactory, this._processLogger);
            var operationRepository = new SystemProcessOperationRepository(connFactory, this._operationLogger);
            var ruleRunRepository   = new SystemProcessOperationRuleRunRepository(connFactory, this._logger);

            var systemProcess = new SystemProcess
            {
                MachineId         = Environment.MachineName,
                ProcessId         = Process.GetCurrentProcess().Id.ToString(),
                InstanceInitiated = DateTime.UtcNow,
                Heartbeat         = DateTime.UtcNow,
                SystemProcessType = SystemProcessType.DataImportService
            };

            systemProcess.Id = systemProcess.GenerateInstanceId();

            await processRepository.Create(systemProcess);

            var systemProcessOperation = new SystemProcessOperation
            {
                SystemProcessId = systemProcess.Id,
                OperationStart  = DateTime.UtcNow,
                OperationState  = OperationState.InProcess
            };

            await operationRepository.Create(systemProcessOperation);

            var systemProcessOperationRuleRun = new SystemProcessOperationRuleRun
            {
                SystemProcessOperationId = systemProcessOperation.Id,
                RuleDescription          = "High Profits",
                RuleVersion       = "1.0",
                ScheduleRuleStart = DateTime.UtcNow,
                ScheduleRuleEnd   = DateTime.UtcNow.AddMinutes(1),
                RuleParameterId   = "1",
                IsBackTest        = true,
                RuleTypeId        = (int)Rules.HighVolume
            };

            await ruleRunRepository.Create(systemProcessOperationRuleRun);

            await ruleRunRepository.Update(systemProcessOperationRuleRun);

            var etc = await ruleRunRepository.Get(new[] { systemProcessOperationRuleRun.Id.ToString() });

            Assert.IsTrue(true);
        }