Наследование: IDateRangeBlock, INumericRangeBlock
Пример #1
0
 public RangeBlockContext(IRangeBlockRepository rangeBlockRepository,
                          ITaskExecutionRepository taskExecutionRepository,
                          string applicationName,
                          string taskName,
                          string taskExecutionId,
                          RangeBlock rangeBlock,
                          string blockExecutionId,
                          string forcedBlockQueueId = "0")
 {
     _rangeBlockRepository    = rangeBlockRepository;
     _taskExecutionRepository = taskExecutionRepository;
     _block             = rangeBlock;
     BlockExecutionId   = blockExecutionId;
     ForcedBlockQueueId = forcedBlockQueueId;
     _applicationName   = applicationName;
     _taskName          = taskName;
     _taskExecutionId   = taskExecutionId;
 }
Пример #2
0
 public RangeBlockContext(IRangeBlockRepository rangeBlockRepository,
     ITaskExecutionRepository taskExecutionRepository,
     string applicationName,
     string taskName,
     string taskExecutionId,
     RangeBlock rangeBlock,
     string blockExecutionId,
     string forcedBlockQueueId = "0")
 {
     _rangeBlockRepository = rangeBlockRepository;
     _taskExecutionRepository = taskExecutionRepository;
     _block = rangeBlock;
     BlockExecutionId = blockExecutionId;
     ForcedBlockQueueId = forcedBlockQueueId;
     _applicationName = applicationName;
     _taskName = taskName;
     _taskExecutionId = taskExecutionId;
 }
        public void If_AsNumericRange_PreviousBlock_ThenLastBlockContainsDates()
        {
            // ARRANGE
            // Create previous blocks
            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = executionContext.TryStart();
                if (startedOk)
                {
                    var rangeBlocks = executionContext.GetNumericRangeBlocks(x => x.WithRange(1, 1000, 100));

                    foreach (var rangeBlock in rangeBlocks)
                    {
                        rangeBlock.Start();
                        rangeBlock.Complete();
                    }
                }
            }

            var expectedLastBlock = new RangeBlock("0", 1, 901, 1000, BlockType.NumericRange);

            // ACT
            INumericRangeBlock lastBlock = null;
            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = executionContext.TryStart();
                if (startedOk)
                {
                    lastBlock = executionContext.GetLastNumericRangeBlock(LastBlockOrder.MaxRangeStartValue);
                }
            }

            // ASSERT
            Assert.AreEqual(expectedLastBlock.RangeBeginAsInt(), lastBlock.StartNumber);
            Assert.AreEqual(expectedLastBlock.RangeEndAsInt(), lastBlock.EndNumber);
        }
        public void If_AsDateRange_PreviousBlock_ThenLastBlockContainsDates()
        {
            // ARRANGE
            // Create previous blocks
            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = executionContext.TryStart();
                if (startedOk)
                {
                    var rangeBlocks = executionContext.GetDateRangeBlocks(x => x.WithRange(new DateTime(2016, 1, 1), new DateTime(2016, 1, 31, 23, 59, 59, 999).AddMilliseconds(-1), new TimeSpan(1, 0, 0, 0))
                        .OverrideConfiguration()
                        .MaximumBlocksToGenerate(50));

                    foreach (var rangeBlock in rangeBlocks)
                    {
                        rangeBlock.Start();
                        rangeBlock.Complete();
                    }
                }
            }

            IDateRangeBlock expectedLastBlock = new RangeBlock("0", 1, new DateTime(2016, 1, 31).Ticks, new DateTime(2016, 1, 31, 23, 59, 59, 997).Ticks, BlockType.DateRange);

            // ACT
            IDateRangeBlock lastBlock = null;
            using (var executionContext = CreateTaskExecutionContext())
            {
                var startedOk = executionContext.TryStart();
                if (startedOk)
                {
                    lastBlock = executionContext.GetLastDateRangeBlock(LastBlockOrder.LastCreated);
                }
            }

            // ASSERT
            Assert.AreEqual(expectedLastBlock.StartDate, lastBlock.StartDate);
            Assert.AreEqual(expectedLastBlock.EndDate, lastBlock.EndDate);
        }