Beispiel #1
0
        public void GetBatchRemoteDesktopProtocolFileParametersTest()
        {
            // Setup cmdlet without required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext    = context;
            cmdlet.PoolId          = null;
            cmdlet.ComputeNodeId   = null;
            cmdlet.ComputeNode     = null;
            cmdlet.DestinationPath = null;

            // Don't go to the service on a Get ComputeNode Remote Desktop call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <ComputeNodeGetRemoteDesktopParameters, ComputeNodeGetRemoteDesktopResponse>();

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

            using (MemoryStream memStream = new MemoryStream())
            {
                // Don't hit the file system during unit tests
                cmdlet.DestinationStream = memStream;

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

                // Fill required compute node details
                cmdlet.PoolId        = "pool";
                cmdlet.ComputeNodeId = "computeNode1";

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

            cmdlet.BatchContext = context;

            // Setup cmdlet to skip confirmation popup
            cmdlet.Force = true;
            commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

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

            cmdlet.Id = "testPool";

            // Don't go to the service on a Delete CloudPool call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudPoolDeleteParameters, CloudPoolDeleteResponse>();

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

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

            cmdlet.BatchContext = context;
            cmdlet.Id           = null;

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

            cmdlet.Id = "testPool";

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

            cmdlet.AutoScaleFormula = "formula";

            // Don't go to the service on an Enable AutoScale call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudPoolEnableAutoScaleParameters, CloudPoolEnableAutoScaleResponse>();

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

            // Verify no exceptions when required parameter is set
            cmdlet.ExecuteCmdlet();
        }
        public void GetBatchNodeFileByTaskTest()
        {
            // Setup cmdlet to get a Task file by name
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.JobId        = "job-1";
            cmdlet.TaskId       = "task";
            cmdlet.Name         = "stdout.txt";
            cmdlet.Filter       = null;

            // Build a NodeFile instead of querying the service on a Get NodeFile Properties call
            NodeFileGetPropertiesResponse response    = BatchTestHelpers.CreateNodeFileGetPropertiesResponse(cmdlet.Name);
            RequestInterceptor            interceptor = BatchTestHelpers.CreateNoOpInterceptor <NodeFileGetPropertiesParameters, NodeFileGetPropertiesResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSNodeFile> pipeline = new List <PSNodeFile>();

            commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSNodeFile>())).Callback <object>(f => pipeline.Add((PSNodeFile)f));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the node file returned from the OM to the pipeline
            Assert.Equal(1, pipeline.Count);
            Assert.Equal(cmdlet.Name, pipeline[0].Name);
        }
        public void GetBatchJobScheduleTest()
        {
            // Setup cmdlet to get a job schedule by id
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = "testJobSchedule";
            cmdlet.Filter       = null;

            // Build a CloudJobSchedule instead of querying the service on a Get CloudJobSchedule call
            CloudJobScheduleGetResponse response    = BatchTestHelpers.CreateCloudJobScheduleGetResponse(cmdlet.Id);
            RequestInterceptor          interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudJobScheduleGetParameters, CloudJobScheduleGetResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSCloudJobSchedule> pipeline = new List <PSCloudJobSchedule>();

            commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSCloudJobSchedule>())).Callback <object>(j => pipeline.Add((PSCloudJobSchedule)j));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the job schedule returned from the OM to the pipeline
            Assert.Equal(1, pipeline.Count);
            Assert.Equal(cmdlet.Id, pipeline[0].Id);
        }
Beispiel #6
0
        public void ResetBatchComputeNodeParametersTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = null;

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

            cmdlet.PoolId = "testPool";

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

            cmdlet.Id = "computeNode1";

            // Don't go to the service on a Reimage ComputeNode call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <ComputeNodeReimageParameters, ComputeNodeReimageResponse>();

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

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

            cmdlet.BatchContext  = context;
            cmdlet.PoolId        = null;
            cmdlet.ComputeNodeId = null;
            cmdlet.Name          = null;
            cmdlet.ComputeNode   = null;
            cmdlet.Filter        = null;

            // Build a NodeFile instead of querying the service on a List NodeFile call
            NodeFileListResponse response    = BatchTestHelpers.CreateNodeFileListResponse(new string[] { cmdlet.Name });
            RequestInterceptor   interceptor = BatchTestHelpers.CreateNoOpInterceptor <NodeFileListParameters, NodeFileListResponse>(response);

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

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

            cmdlet.PoolId        = "pool";
            cmdlet.ComputeNodeId = "computeNode1";

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

            cmdlet.BatchContext = context;

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

            cmdlet.JobId = "job-1";

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

            cmdlet.Id = "testTask";

            // Don't go to the service on a Terminate CloudTask call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudTaskTerminateParameters, CloudTaskTerminateResponse>();

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

            // Verify no exceptions when required parameters are set
            cmdlet.ExecuteCmdlet();
        }
Beispiel #9
0
        public void GetBatchTaskParametersTest()
        {
            // Setup cmdlet without required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.JobId        = null;
            cmdlet.Job          = null;
            cmdlet.Filter       = null;

            // Build a CloudTask instead of querying the service on a List CloudTask call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudTaskListParameters, CloudTaskListResponse>();

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

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

            cmdlet.JobId = "job-1";

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

            cmdlet.BatchContext = context;

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

            cmdlet.PoolId        = "testPool";
            cmdlet.ComputeNodeId = "computeNode1";

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

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

            // Don't go to the service on an Add ComputeNodeUser call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <ComputeNodeAddUserParameters, ComputeNodeAddUserResponse>();

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

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

            cmdlet.BatchContext = context;
            cmdlet.Id           = null;

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

            cmdlet.Id = "testPool";

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

            cmdlet.TargetOSVersion = "targetOS";

            // Don't go to the service on an Upgrade OS call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudPoolUpgradeOSParameters, CloudPoolUpgradeOSResponse>();

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

            // Verify no exceptions when required parameter is set
            cmdlet.ExecuteCmdlet();
        }
        public void ListNodeFilesByComputeNodeMaxCountTest()
        {
            // Verify default max count
            Assert.Equal(Microsoft.Azure.Commands.Batch.Utils.Constants.DefaultMaxCount, cmdlet.MaxCount);

            // Setup cmdlet to list vm files and a max count.
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext  = context;
            cmdlet.PoolId        = "pool";
            cmdlet.ComputeNodeId = "computeNode1";
            cmdlet.Name          = null;
            cmdlet.Filter        = null;
            int maxCount = 2;

            cmdlet.MaxCount = maxCount;

            string[] namesOfConstructedNodeFiles = new[] { "startup", "workitems", "shared" };

            // Build some NodeFiles instead of querying the service on a List NodeFiles call
            NodeFileListResponse response    = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
            RequestInterceptor   interceptor = BatchTestHelpers.CreateNoOpInterceptor <NodeFileListParameters, NodeFileListResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSNodeFile> pipeline = new List <PSNodeFile>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSNodeFile>()))
            .Callback <object>(f => pipeline.Add((PSNodeFile)f));

            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(namesOfConstructedNodeFiles.Length, pipeline.Count);
        }
        public void ListJobsMaxCountTest()
        {
            // Verify default max count
            Assert.Equal(Microsoft.Azure.Commands.Batch.Utils.Constants.DefaultMaxCount, cmdlet.MaxCount);

            // Setup cmdlet to list jobs without filters and a max count
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext  = context;
            cmdlet.JobScheduleId = "jobSchedule";
            cmdlet.Id            = null;
            cmdlet.Filter        = null;
            int maxCount = 2;

            cmdlet.MaxCount = maxCount;

            string[] idsOfConstructedJobs = new[] { "job-1", "job-2", "job-3" };

            // Build some CloudJobs instead of querying the service on a List CloudJobs call
            CloudJobListResponse response    = BatchTestHelpers.CreateCloudJobListResponse(idsOfConstructedJobs);
            RequestInterceptor   interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudJobListParameters, CloudJobListResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSCloudJob> pipeline = new List <PSCloudJob>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSCloudJob>()))
            .Callback <object>(j => pipeline.Add((PSCloudJob)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(idsOfConstructedJobs.Length, pipeline.Count);
        }
        public void ListBatchNodeFilesByComputeNodeWithoutFiltersTest()
        {
            // Setup cmdlet to list vm files without filters.
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext  = context;
            cmdlet.PoolId        = "pool";
            cmdlet.ComputeNodeId = "computeNode1";
            cmdlet.Name          = null;
            cmdlet.Filter        = null;

            string[] namesOfConstructedNodeFiles = new[] { "startup", "workitems", "shared" };

            // Build some NodeFiles instead of querying the service on a List NodeFiles call
            NodeFileListResponse response    = BatchTestHelpers.CreateNodeFileListResponse(namesOfConstructedNodeFiles);
            RequestInterceptor   interceptor = BatchTestHelpers.CreateNoOpInterceptor <NodeFileListParameters, NodeFileListResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSNodeFile> pipeline = new List <PSNodeFile>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSNodeFile>()))
            .Callback <object>(f => pipeline.Add((PSNodeFile)f));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the constructed node files to the pipeline
            Assert.Equal(3, pipeline.Count);
            int taskCount = 0;

            foreach (PSNodeFile f in pipeline)
            {
                Assert.True(namesOfConstructedNodeFiles.Contains(f.Name));
                taskCount++;
            }
            Assert.Equal(namesOfConstructedNodeFiles.Length, taskCount);
        }
        public void ListBatchJobsByODataFilterTest()
        {
            // Setup cmdlet to list jobs using an OData filter. Use JobScheduleId input.
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext  = context;
            cmdlet.JobScheduleId = "jobSchedule";
            cmdlet.Id            = null;
            cmdlet.Filter        = "state -eq 'active'";

            string[] idsOfConstructedJobs = new[] { "job-1", "job-2" };

            // Build some CloudJobs instead of querying the service on a List CloudJobs call
            CloudJobListResponse response    = BatchTestHelpers.CreateCloudJobListResponse(idsOfConstructedJobs);
            RequestInterceptor   interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudJobListParameters, CloudJobListResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSCloudJob> pipeline = new List <PSCloudJob>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSCloudJob>()))
            .Callback <object>(j => pipeline.Add((PSCloudJob)j));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the constructed jobs to the pipeline
            Assert.Equal(2, pipeline.Count);
            int jobCount = 0;

            foreach (PSCloudJob j in pipeline)
            {
                Assert.True(idsOfConstructedJobs.Contains(j.Id));
                jobCount++;
            }
            Assert.Equal(idsOfConstructedJobs.Length, jobCount);
        }
Beispiel #16
0
        public void ListBatchTasksWithoutFiltersTest()
        {
            // Setup cmdlet to list tasks without filters. Use WorkItemName and JobName.
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.JobId        = "job-1";
            cmdlet.Id           = null;
            cmdlet.Filter       = null;

            string[] idsOfConstructedTasks = new[] { "testTask1", "testTask2", "testTask3" };

            // Build some CloudTasks instead of querying the service on a List CloudTasks call
            CloudTaskListResponse response    = BatchTestHelpers.CreateCloudTaskListResponse(idsOfConstructedTasks);
            RequestInterceptor    interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudTaskListParameters, CloudTaskListResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSCloudTask> pipeline = new List <PSCloudTask>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSCloudTask>()))
            .Callback <object>(t => pipeline.Add((PSCloudTask)t));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the constructed tasks to the pipeline
            Assert.Equal(3, pipeline.Count);
            int taskCount = 0;

            foreach (PSCloudTask t in pipeline)
            {
                Assert.True(idsOfConstructedTasks.Contains(t.Id));
                taskCount++;
            }
            Assert.Equal(idsOfConstructedTasks.Length, taskCount);
        }
        public void ListBatchComputeNodesByODataFilterTest()
        {
            // Setup cmdlet to list vms using an OData filter.
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.PoolId       = "pool";
            cmdlet.Id           = null;
            cmdlet.Filter       = "state -eq 'idle'";

            string[] idsOfConstructedComputeNodes = new[] { "computeNode1", "computeNode2" };

            // Build some compute nodes instead of querying the service on a List ComputeNodes call
            ComputeNodeListResponse response    = BatchTestHelpers.CreateComputeNodeListResponse(idsOfConstructedComputeNodes);
            RequestInterceptor      interceptor = BatchTestHelpers.CreateNoOpInterceptor <ComputeNodeListParameters, ComputeNodeListResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSComputeNode> pipeline = new List <PSComputeNode>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSComputeNode>()))
            .Callback <object>(c => pipeline.Add((PSComputeNode)c));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the constructed compute nodes to the pipeline
            Assert.Equal(2, pipeline.Count);
            int computeNodeCount = 0;

            foreach (PSComputeNode c in pipeline)
            {
                Assert.True(idsOfConstructedComputeNodes.Contains(c.Id));
                computeNodeCount++;
            }
            Assert.Equal(idsOfConstructedComputeNodes.Length, computeNodeCount);
        }
Beispiel #18
0
        public void ListBatchPoolByODataFilterTest()
        {
            // Setup cmdlet to list pools using an OData filter
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = null;
            cmdlet.Filter       = "startswith(id,'test')";

            string[] idsOfConstructedPools = new[] { "test1", "test2" };

            // Build some CloudPools instead of querying the service on a List CloudPools call
            CloudPoolListResponse response    = BatchTestHelpers.CreateCloudPoolListResponse(idsOfConstructedPools);
            RequestInterceptor    interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudPoolListParameters, CloudPoolListResponse>(response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSCloudPool> pipeline = new List <PSCloudPool>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSCloudPool>()))
            .Callback <object>(p => pipeline.Add((PSCloudPool)p));

            cmdlet.ExecuteCmdlet();

            // Verify that the cmdlet wrote the constructed pools to the pipeline
            Assert.Equal(2, pipeline.Count);
            int poolCount = 0;

            foreach (PSCloudPool p in pipeline)
            {
                Assert.True(idsOfConstructedPools.Contains(p.Id));
                poolCount++;
            }
            Assert.Equal(idsOfConstructedPools.Length, poolCount);
        }
        public void StopJobScheduleParametersTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;
            cmdlet.Id           = null;

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

            cmdlet.Id = "testJobSchedule";

            // Don't go to the service on a Terminate CloudJobSchedule call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudJobScheduleTerminateParameters, CloudJobScheduleTerminateResponse>();

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

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

            cmdlet.BatchContext = context;
            cmdlet.JobId        = null;
            cmdlet.TaskId       = null;
            cmdlet.Name         = null;
            cmdlet.Task         = null;
            cmdlet.Filter       = null;

            // Build a NodeFile instead of querying the service on a List NodeFile call
            NodeFileListResponse response    = BatchTestHelpers.CreateNodeFileListResponse(new string[] { cmdlet.Name });
            RequestInterceptor   interceptor = BatchTestHelpers.CreateNoOpInterceptor <NodeFileListParameters, NodeFileListResponse>(response);

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

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

            cmdlet.JobId  = "job-1";
            cmdlet.TaskId = "task";

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

            cmdlet.JobId  = null;
            cmdlet.TaskId = null;
            cmdlet.Task   = new PSCloudTask("task", "cmd /c dir /s");

            // Verify that we don't get an argument exception. We should get an InvalidOperationException though since the task is unbound
            Assert.Throws <InvalidOperationException>(() => cmdlet.ExecuteCmdlet());
        }
        public void NewBatchPoolParametersTest()
        {
            // Setup cmdlet without the required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

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

            cmdlet.Id = "testPool";
            cmdlet.VirtualMachineSize = "small";
            cmdlet.OSFamily           = "4";

            // Don't go to the service on an Add CloudPool call
            RequestInterceptor interceptor = BatchTestHelpers.CreateNoOpInterceptor <CloudPoolAddParameters, CloudPoolAddResponse>();

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

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