예제 #1
0
        public void If_KeepAlive_ThenKeepAliveContinuesUntilExecutionContextDies()
        {
            // ARRANGE
            var executionHelper  = new ExecutionsHelper();
            var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName);

            executionHelper.InsertAvailableExecutionToken(taskDefinitionId);

            // ACT
            StartContextWithoutUsingOrComplete();
            GC.Collect(0, GCCollectionMode.Forced); // referenceless context is collected
            Thread.Sleep(6000);

            // ASSERT
            var expectedLastKeepAliveMax = DateTime.UtcNow.AddSeconds(-5);
            var lastKeepAlive            = executionHelper.GetLastKeepAlive(taskDefinitionId);

            Assert.IsTrue(lastKeepAlive < expectedLastKeepAliveMax);
        }