コード例 #1
0
        public void AutoCompletionSettingIsSentToService()
        {
            // Setup cmdlet without the required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

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

            CloudJob cloudJob = new Azure.Batch.Protocol.Models.CloudJob(
                id: "job-id",
                poolInfo: new Azure.Batch.Protocol.Models.PoolInformation(),
                onAllTasksComplete: (Azure.Batch.Protocol.Models.OnAllTasksComplete?)OnAllTasksComplete.TerminateJob);

            cmdlet.Job = new PSCloudJob(BatchTestHelpers.CreateFakeBoundJob(context, cloudJob));
            cmdlet.Job.OnAllTasksComplete = OnAllTasksComplete.TerminateJob;

            RequestInterceptor interceptor =
                BatchTestHelpers.CreateFakeServiceResponseInterceptor <JobUpdateParameter, JobUpdateOptions, AzureOperationHeaderResponse <JobUpdateHeaders> >(
                    new AzureOperationHeaderResponse <JobUpdateHeaders>(),
                    request =>
            {
                Assert.Equal((OnAllTasksComplete)request.Parameters.OnAllTasksComplete, OnAllTasksComplete.TerminateJob);
            });

            cmdlet.AdditionalBehaviors = new BatchClientBehavior[] { interceptor };

            // Verify that no exceptions occur
            cmdlet.ExecuteCmdlet();
        }
コード例 #2
0
        public void AutoCompletionSettingIsSentToService()
        {
            // Setup cmdlet without the required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
            cmdlet.BatchContext = context;

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

            CloudJob cloudJob = new Azure.Batch.Protocol.Models.CloudJob(
                id: "job-id",
                poolInfo: new Azure.Batch.Protocol.Models.PoolInformation(),
                onAllTasksComplete: (Azure.Batch.Protocol.Models.OnAllTasksComplete?)OnAllTasksComplete.TerminateJob);

            cmdlet.Job = new PSCloudJob(BatchTestHelpers.CreateFakeBoundJob(context, cloudJob));
            cmdlet.Job.OnAllTasksComplete = OnAllTasksComplete.TerminateJob;

            RequestInterceptor interceptor =
                BatchTestHelpers.CreateFakeServiceResponseInterceptor<JobUpdateParameter, JobUpdateOptions, AzureOperationHeaderResponse<JobUpdateHeaders>>(
                    new AzureOperationHeaderResponse<JobUpdateHeaders>(),
                    request =>
                    {
                        Assert.Equal((OnAllTasksComplete)request.Parameters.OnAllTasksComplete, OnAllTasksComplete.TerminateJob);
                    });

            cmdlet.AdditionalBehaviors = new BatchClientBehavior[] { interceptor };

            // Verify that no exceptions occur
            cmdlet.ExecuteCmdlet();
        }