internal JobPreparationAndReleaseTaskExecutionInformation(Models.JobPreparationAndReleaseTaskExecutionInformation protocolObject) { this.computeNodeId = protocolObject.NodeId; this.computeNodeUrl = protocolObject.NodeUrl; this.jobPreparationTaskExecutionInformation = UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.JobPreparationTaskExecutionInfo, o => new JobPreparationTaskExecutionInformation(o).Freeze()); this.jobReleaseTaskExecutionInformation = UtilitiesInternal.CreateObjectWithNullCheck(protocolObject.JobReleaseTaskExecutionInfo, o => new JobReleaseTaskExecutionInformation(o).Freeze()); this.poolId = protocolObject.PoolId; }
public void GetBatchJobPreparationAndReleaseTaskStatusTestMaxCountTest() { // Verify default max count Assert.Equal(Utils.Constants.DefaultMaxCount, cmdlet.MaxCount); // Setup cmdlet to list jobs without filters and a max count BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; cmdlet.Id = "test"; cmdlet.Filter = null; const int maxCount = 2; cmdlet.MaxCount = maxCount; const string poolId = "Test"; // Build some PrepAndReleaseTaskStatuses instead of querying the service on a List CloudJobs call var taskExecutionInformationList = new List <ProxyModels.JobPreparationAndReleaseTaskExecutionInformation>(); const int countReturned = 3; for (int i = 0; i < countReturned; i++) { var jpjrInfo = new ProxyModels.JobPreparationAndReleaseTaskExecutionInformation( poolId: poolId, nodeId: Guid.NewGuid().ToString(), jobPreparationTaskExecutionInfo: new ProxyModels.JobPreparationTaskExecutionInformation( retryCount: 0, state: ProxyModels.JobPreparationTaskState.Completed, startTime: DateTime.UtcNow), jobReleaseTaskExecutionInfo: new ProxyModels.JobReleaseTaskExecutionInformation( state: ProxyModels.JobReleaseTaskState.Completed, startTime: DateTime.UtcNow)); taskExecutionInformationList.Add(jpjrInfo); } var response = BatchTestHelpers.CreateJobPreparationAndReleaseTaskStatusListResponse(taskExecutionInformationList); RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor < ProxyModels.JobListPreparationAndReleaseTaskStatusOptions, AzureOperationResponse <IPage <ProxyModels.JobPreparationAndReleaseTaskExecutionInformation>, ProxyModels.JobListPreparationAndReleaseTaskStatusHeaders> >(response); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Setup the cmdlet to write pipeline output to a list that can be examined later var pipeline = new List <PSJobPreparationAndReleaseTaskExecutionInformation>(); commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSJobPreparationAndReleaseTaskExecutionInformation>())) .Callback <object>(j => pipeline.Add((PSJobPreparationAndReleaseTaskExecutionInformation)j)); cmdlet.ExecuteCmdlet(); // Verify that the max count was respected Assert.Equal(maxCount, pipeline.Count); // Verify setting max count <= 0 doesn't return nothing cmdlet.MaxCount = -5; pipeline.Clear(); cmdlet.ExecuteCmdlet(); Assert.Equal(countReturned, pipeline.Count); }