public async Task If_AsDateRange_PreviousBlockIsPhantom_ThenLastBlockIsNotThePhantom() { // ARRANGE // Create previous blocks using (var executionContext = CreateTaskExecutionContext()) { var startedOk = await executionContext.TryStartAsync(); if (startedOk) { var rangeBlocks = await executionContext.GetDateRangeBlocksAsync(x => x.WithRange(new DateTime(2016, 1, 1), new DateTime(2016, 1, 2), new TimeSpan(2, 0, 0, 0)) .OverrideConfiguration() .MaximumBlocksToGenerate(50)); foreach (var rangeBlock in rangeBlocks) { await rangeBlock.StartAsync(); await rangeBlock.CompleteAsync(); } } } _blocksHelper.InsertPhantomDateRangeBlock(TestConstants.ApplicationName, TestConstants.TaskName, new DateTime(2015, 1, 1), new DateTime(2015, 1, 2)); // ACT IDateRangeBlock lastBlock = null; using (var executionContext = CreateTaskExecutionContext()) { var startedOk = await executionContext.TryStartAsync(); if (startedOk) { lastBlock = await executionContext.GetLastDateRangeBlockAsync(LastBlockOrder.LastCreated); } } // ASSERT Assert.Equal(new DateTime(2016, 1, 1), lastBlock.StartDate); Assert.Equal(new DateTime(2016, 1, 2), lastBlock.EndDate); }