TryCancelJob() 개인적인 메소드

private TryCancelJob ( System.Guid jobId ) : IHttpActionResult
jobId System.Guid
리턴 IHttpActionResult
예제 #1
0
		public void ShouldReturnBadRequestWhenCancelJobWithNoId()
		{
			_workerWrapper = new WorkerWrapper(new ShortRunningInvokeHandlerFake(),
			                                   _nodeConfigurationFake,
			                                   _nodeStartupNotification,
			                                   _pingToManagerFake,
			                                   _sendJobDoneTimer,
			                                   _sendJobCanceledTimer,
			                                   _sendJobFaultedTimer,
			                                   _trySendJobDetailToManagerTimerFake);

			_nodeController = new NodeController(_workerWrapper, _nodeConfigurationFake)
			{
				Request = new HttpRequestMessage(),
				Configuration = new HttpConfiguration()
			};

			var actionResult = _nodeController.TryCancelJob(Guid.Empty);

			Assert.IsTrue(actionResult.ExecuteAsync(new CancellationToken())
							  .Result.StatusCode ==
						  HttpStatusCode.BadRequest);
		}
예제 #2
0
		public void CancelJobShouldReturnNotFoundWhenNodeIsIdle()
		{
			_workerWrapper = new WorkerWrapper(new ShortRunningInvokeHandlerFake(),
			                                   _nodeConfigurationFake,
			                                   _nodeStartupNotification,
			                                   _pingToManagerFake,
			                                   _sendJobDoneTimer,
			                                   _sendJobCanceledTimer,
			                                   _sendJobFaultedTimer,
			                                   _trySendJobDetailToManagerTimerFake);

			_nodeController = new NodeController(_workerWrapper, _nodeConfigurationFake)
			{
				Request = new HttpRequestMessage()
			};

			IHttpActionResult actionResultCancel = _nodeController.TryCancelJob(_jobQueueItemEntity.JobId);

			Assert.IsTrue(actionResultCancel.ExecuteAsync(new CancellationToken())
							  .Result.StatusCode ==
						  HttpStatusCode.NotFound);
		}
예제 #3
0
		public void CancelJobShouldReturnOkWhenSuccessful()
		{
			_workerWrapper = new WorkerWrapper(new LongRunningInvokeHandlerFake(),
			                                   _nodeConfigurationFake,
			                                   _nodeStartupNotification,
			                                   _pingToManagerFake,
			                                   _sendJobDoneTimer,
			                                   _sendJobCanceledTimer,
			                                   _sendJobFaultedTimer,
			                                   _trySendJobDetailToManagerTimerFake);

			_nodeController = new NodeController(_workerWrapper, _nodeConfigurationFake)
			{
				Request = new HttpRequestMessage()
			};

			_nodeController.PrepareToStartJob(_jobQueueItemEntity);
			_nodeController.StartJob(_jobQueueItemEntity.JobId);

			//is this to make sure the job has started before cancelling?
			_trySendJobDetailToManagerTimerFake.WaitHandle.Wait(500);

			var actionResult = _nodeController.TryCancelJob(_jobQueueItemEntity.JobId);

			Assert.IsTrue(actionResult.ExecuteAsync(new CancellationToken())
							  .Result.StatusCode ==
						  HttpStatusCode.OK);
		}