Esempio n. 1
0
        public async Task Update_UpdatesADistributedRuleEntity_AsExpected()
        {
            var connFactory          = new ConnectionStringFactory(this._config);
            var processRepository    = new SystemProcessRepository(connFactory, this._processLogger);
            var operationRepository  = new SystemProcessOperationRepository(connFactory, this._operationLogger);
            var distributeRepository = new SystemProcessOperationDistributeRuleRepository(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 SystemProcessOperationDistributeRule
            {
                SystemProcessOperationId = systemProcessOperation.Id,
                ScheduleRuleInitialStart = DateTime.UtcNow,
                ScheduleRuleInitialEnd   = DateTime.UtcNow.AddMinutes(30),
                RulesDistributed         = "High Profits, Marking The Close"
            };

            await distributeRepository.Create(systemProcessOperationRuleRun);

            systemProcessOperationRuleRun.RulesDistributed = "Spoofing";

            await distributeRepository.Update(systemProcessOperationRuleRun);

            Assert.IsTrue(true);
        }
        public ISystemProcessOperationDistributeRuleContext CreateAndStartDistributeRuleContext(
            DateTime?initialStart,
            DateTime?initialEnd,
            string rules)
        {
            var op = new SystemProcessOperationDistributeRule
            {
                SystemProcessId          = this._systemProcessOperation.SystemProcessId,
                SystemProcessOperationId = this._systemProcessOperation.Id,
                ScheduleRuleInitialStart = initialStart,
                ScheduleRuleInitialEnd   = initialEnd,
                RulesDistributed         = rules
            };

            var ctx = this._distributeRuleContextFactory.Build(this);

            ctx.StartEvent(op);

            return(ctx);
        }