public async Task If_KeepAliveMode_OneTokenExistsAndConcurrencyLimitIsUnlimited_ThenRemoveAvailableTokenAndCreateOneNewUnlimitedToken() { // ARRANGE var executionHelper = new ExecutionsHelper(); var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName); executionHelper.InsertAvailableExecutionToken(taskDefinitionId); var startRequest = CreateKeepAliveStartRequest(-1); // ACT var sut = CreateSut(); await sut.StartAsync(startRequest); // ASSERT var tokensList = executionHelper.GetExecutionTokens(TestConstants.ApplicationName, TestConstants.TaskName); Assert.Equal(1, tokensList.Tokens.Count(x => x.Status == ExecutionTokenStatus.Unlimited)); }
public void If_KeepAliveMode_OneTokenExistsAndConcurrencyLimitIsFour_ThenCreateThreeNewTokens() { // ARRANGE var executionHelper = new ExecutionsHelper(); var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName); executionHelper.InsertAvailableExecutionToken(taskDefinitionId); var startRequest = CreateKeepAliveStartRequest(4); // ACT var sut = CreateSut(); sut.Start(startRequest); // ASSERT var tokensList = executionHelper.GetExecutionTokens(TestConstants.ApplicationName, TestConstants.TaskName); Assert.AreEqual(1, tokensList.Tokens.Count(x => x.Status == ExecutionTokenStatus.Unavailable)); Assert.AreEqual(3, tokensList.Tokens.Count(x => x.Status == ExecutionTokenStatus.Available)); }
public async Task If_KeepAliveMode_TwoUnavailableTokensExistsAndConcurrencyLimitIsOne_ThenRemoveOneUnavailableToken() { // ARRANGE var executionHelper = new ExecutionsHelper(); var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName); executionHelper.InsertExecutionToken(taskDefinitionId, new List <Tuple <ExecutionTokenStatus, string> >() { new Tuple <ExecutionTokenStatus, string>(ExecutionTokenStatus.Unavailable, "0"), new Tuple <ExecutionTokenStatus, string>(ExecutionTokenStatus.Unavailable, "1") }); var startRequest = CreateKeepAliveStartRequest(1); // ACT var sut = CreateSut(); await sut.StartAsync(startRequest); // ASSERT var tokensList = executionHelper.GetExecutionTokens(TestConstants.ApplicationName, TestConstants.TaskName); Assert.Equal(1, tokensList.Tokens.Count(x => x.Status == ExecutionTokenStatus.Unavailable)); }
public void If_KeepAliveMode_OneAvailableTokenAndOneUnavailableTokensExistsAndConcurrencyLimitIsOne_ThenRemoveAvailableToken_AndSoDenyStart() { // ARRANGE var executionHelper = new ExecutionsHelper(); var taskDefinitionId = executionHelper.InsertTask(TestConstants.ApplicationName, TestConstants.TaskName); executionHelper.InsertExecutionToken(taskDefinitionId, new List <Tuple <ExecutionTokenStatus, string> >() { new Tuple <ExecutionTokenStatus, string>(ExecutionTokenStatus.Unavailable, "0"), new Tuple <ExecutionTokenStatus, string>(ExecutionTokenStatus.Available, "1") }); var startRequest = CreateKeepAliveStartRequest(1); // ACT var sut = CreateSut(); var result = sut.Start(startRequest); // ASSERT var tokensList = executionHelper.GetExecutionTokens(TestConstants.ApplicationName, TestConstants.TaskName); Assert.AreEqual(GrantStatus.Denied, result.GrantStatus); Assert.AreEqual(1, tokensList.Tokens.Count(x => x.Status == ExecutionTokenStatus.Unavailable)); }