コード例 #1
0
        public async Task If_AsDateRangeNoBlockNeeded_ThenEmptyListAndEventPersisted()
        {
            // ARRANGE
            // ACT and // ASSERT
            bool startedOk;

            using (var executionContext = CreateTaskExecutionContext())
            {
                startedOk = await executionContext.TryStartAsync();

                Assert.True(startedOk);
                if (startedOk)
                {
                    var fromDate      = DateTime.UtcNow;
                    var toDate        = DateTime.UtcNow.AddHours(-12);
                    var maxBlockRange = new TimeSpan(0, 30, 0);
                    var rangeBlocks   = await executionContext.GetDateRangeBlocksAsync(x => x.WithRange(fromDate, toDate, maxBlockRange));

                    Assert.Equal(0, _blocksHelper.GetBlockCount(TestConstants.ApplicationName, TestConstants.TaskName));

                    var lastEvent = _executionHelper.GetLastEvent(_taskDefinitionId);
                    Assert.Equal(EventType.CheckPoint, lastEvent.Item1);
                    Assert.Equal("No values for generate the block. Emtpy Block context returned.", lastEvent.Item2);
                }
            }
        }
コード例 #2
0
        public void If_Checkpoint_ThenCheckpointEventCreated()
        {
            // ARRANGE
            var executionHelper = new ExecutionsHelper();

            // ACT
            bool startedOk;
            Tuple <EventType, string> lastEvent = null;

            using (var executionContext = ClientHelper.GetExecutionContext(TestConstants.TaskName, ClientHelper.GetDefaultTaskConfigurationWithKeepAliveAndReprocessing()))
            {
                startedOk = executionContext.TryStart();
                executionContext.Checkpoint("Test checkpoint");
                lastEvent = executionHelper.GetLastEvent(_taskDefinitionId);
            }

            // ASSERT
            Assert.AreEqual(EventType.CheckPoint, lastEvent.Item1);
            Assert.AreEqual("Test checkpoint", lastEvent.Item2);
        }
        public void If_NoBlockNeeded_ThenEmptyListAndEventPersisted()
        {
            // ARRANGE
            // ACT and // ASSERT
            bool startedOk;

            using (var executionContext = CreateTaskExecutionContext())
            {
                startedOk = executionContext.TryStart();
                Assert.AreEqual(true, startedOk);
                if (startedOk)
                {
                    var rangeBlocks = executionContext.GetObjectBlocks <string>(x => x.WithNoNewBlocks());
                    Assert.AreEqual(0, _blocksHelper.GetBlockCount(TestConstants.ApplicationName, TestConstants.TaskName));

                    var lastEvent = _executionHelper.GetLastEvent(_taskDefinitionId);
                    Assert.AreEqual(EventType.CheckPoint, lastEvent.Item1);
                    Assert.AreEqual("No values for generate the block. Emtpy Block context returned.", lastEvent.Item2);
                }
            }
        }