public InsertKeepAliveTaskExecution ( int taskDefinitionId ) : string | ||
taskDefinitionId | int | |
Результат | string |
public void If_KeepAliveMode_TokenNotAvailableAndNothingInQueue_ThenAddToQueueAndDeny() { // ARRANGE var executionHelper = new ExecutionsHelper(); var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName); executionHelper.InsertUnlimitedExecutionToken(taskDefinitionId); // Create execution 1 and assign critical section to it var taskExecutionId1 = executionHelper.InsertKeepAliveTaskExecution(taskDefinitionId); executionHelper.InsertUnavailableCriticalSectionToken(taskDefinitionId, taskExecutionId1); // Create second execution var taskExecutionId2 = executionHelper.InsertKeepAliveTaskExecution(taskDefinitionId); var request = new StartCriticalSectionRequest(new TaskId(TestConstants.ApplicationName, TestConstants.TaskName), taskExecutionId2, TaskDeathMode.KeepAlive, CriticalSectionType.User); request.KeepAliveDeathThreshold = new TimeSpan(0, 1, 0); // ACT var sut = CreateSut(); var response = sut.Start(request); // ASSERT var isInQueue = executionHelper.GetQueueCount(taskExecutionId2) == 1; Assert.AreEqual(true, isInQueue); Assert.AreEqual(GrantStatus.Denied, response.GrantStatus); }
public void If_KeepAliveMode_TokenAvailableAndNothingInQueue_ThenGrant() { // ARRANGE var executionHelper = new ExecutionsHelper(); var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName); var taskExecutionId = executionHelper.InsertKeepAliveTaskExecution(taskDefinitionId); executionHelper.InsertUnlimitedExecutionToken(taskDefinitionId); var request = new StartCriticalSectionRequest(new TaskId(TestConstants.ApplicationName, TestConstants.TaskName), taskExecutionId, TaskDeathMode.KeepAlive, CriticalSectionType.User); request.KeepAliveDeathThreshold = new TimeSpan(0, 1, 0); // ACT var sut = CreateSut(); var response = sut.Start(request); // ASSERT Assert.AreEqual(GrantStatus.Granted, response.GrantStatus); }
public void If_KeepAliveMode_TokenAvailableAndIsNotFirstInQueueButFirstHasCompleted_ThenRemoveBothFromQueueAndGrant() { // ARRANGE var executionHelper = new ExecutionsHelper(); var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName); executionHelper.InsertUnlimitedExecutionToken(taskDefinitionId); // Create execution 1 and add it to the queue var taskExecutionId1 = executionHelper.InsertKeepAliveTaskExecution(taskDefinitionId); executionHelper.SetKeepAlive(taskExecutionId1); executionHelper.InsertIntoCriticalSectionQueue(taskDefinitionId, 1, taskExecutionId1); executionHelper.SetTaskExecutionAsCompleted(taskExecutionId1); // Create execution 2 and add it to the queue var taskExecutionId2 = executionHelper.InsertKeepAliveTaskExecution(taskDefinitionId); executionHelper.SetKeepAlive(taskExecutionId2); executionHelper.InsertIntoCriticalSectionQueue(taskDefinitionId, 2, taskExecutionId2); // Create an available critical section token executionHelper.InsertAvailableCriticalSectionToken(taskDefinitionId, "0"); var request = new StartCriticalSectionRequest(new TaskId(TestConstants.ApplicationName, TestConstants.TaskName), taskExecutionId2, TaskDeathMode.KeepAlive, CriticalSectionType.User); request.KeepAliveDeathThreshold = new TimeSpan(0, 30, 0); // ACT var sut = CreateSut(); var response = sut.Start(request); // ASSERT var numberOfQueueRecordsForExecution1 = executionHelper.GetQueueCount(taskExecutionId1); var numberOfQueueRecordsForExecution2 = executionHelper.GetQueueCount(taskExecutionId2); Assert.AreEqual(0, numberOfQueueRecordsForExecution1); Assert.AreEqual(0, numberOfQueueRecordsForExecution2); Assert.AreEqual(GrantStatus.Granted, response.GrantStatus); }