Beispiel #1
0
        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.Path         = "stdout.txt";
            cmdlet.Filter       = null;

            // Build a NodeFile instead of querying the service on a Get NodeFile Properties call
            AzureOperationHeaderResponse <ProxyModels.FileGetPropertiesFromTaskHeaders> response = BatchTestHelpers.CreateNodeFileGetPropertiesByTaskResponse();
            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                ProxyModels.FileGetPropertiesFromTaskOptions,
                AzureOperationHeaderResponse <ProxyModels.FileGetPropertiesFromTaskHeaders> >(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.Single(pipeline);
            Assert.Equal(cmdlet.Path, pipeline[0].Path);
        }