public async Task Update_Operation_AddsToDb()
        {
            var connFactory      = new ConnectionStringFactory(this._config);
            var parentRepository = new SystemProcessRepository(connFactory, this._processLogger);
            var repository       = new SystemProcessOperationRepository(connFactory, this._operationLogger);

            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 parentRepository.Create(systemProcess);

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

            await repository.Create(systemProcessOperation);

            systemProcessOperation.OperationEnd = DateTime.UtcNow;

            await repository.Update(systemProcessOperation);

            Assert.IsTrue(true);
        }
        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);
        }
Beispiel #3
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);
        }