public void NewBatchJobParametersTest()
        {
            // Setup cmdlet without the required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

            cmdlet.Id = "testJob";
            cmdlet.OnAllTasksComplete = Azure.Batch.Common.OnAllTasksComplete.TerminateJob;
            cmdlet.OnTaskFailure      = Azure.Batch.Common.OnTaskFailure.PerformExitOptionsJobAction;

            // Don't go to the service on an Add CloudJob call
            var interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <JobAddParameter, JobAddOptions, AzureOperationHeaderResponse <JobAddHeaders> >(
                new AzureOperationHeaderResponse <JobAddHeaders>(),
                request =>
            {
                Assert.Equal(OnAllTasksComplete.TerminateJob, request.Parameters.OnAllTasksComplete);
                Assert.Equal(OnTaskFailure.PerformExitOptionsJobAction, request.Parameters.OnTaskFailure);
            });

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };

            // Verify no exceptions when required parameters are set
            cmdlet.ExecuteCmdlet();
        }
        public void NewBatchJobParametersTest()
        {
            // Setup cmdlet without the required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

            cmdlet.Id = "testJob";

            // Don't go to the service on an Add CloudJob call
            RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
            {
                BatchRequest <CloudJobAddParameters, CloudJobAddResponse> request =
                    (BatchRequest <CloudJobAddParameters, CloudJobAddResponse>)baseRequest;

                request.ServiceRequestFunc = (cancellationToken) =>
                {
                    CloudJobAddResponse response    = new CloudJobAddResponse();
                    Task <CloudJobAddResponse> task = Task.FromResult(response);
                    return(task);
                };
            });

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };

            // Verify no exceptions when required parameters are set
            cmdlet.ExecuteCmdlet();
        }
Пример #3
0
        public void NewBatchJobParametersTest()
        {
            // Setup cmdlet without the required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            Assert.Throws <ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

            cmdlet.Id = "testJob";

            // Don't go to the service on an Add CloudJob call
            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <JobAddParameter, JobAddOptions, AzureOperationHeaderResponse <JobAddHeaders> >();

            cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>()
            {
                interceptor
            };

            // Verify no exceptions when required parameters are set
            cmdlet.ExecuteCmdlet();
        }