예제 #1
0
        public void GetBatchNodeFileByComputeNodeTest()
        {
            // Setup cmdlet to get a Task file by name
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext  = context;
            cmdlet.PoolId        = "pool";
            cmdlet.ComputeNodeId = "vm1";
            cmdlet.Path          = "startup\\stdout.txt";
            cmdlet.Filter        = null;

            // Build a NodeFile instead of querying the service on a Get NodeFile Properties call
            AzureOperationHeaderResponse <ProxyModels.FileGetPropertiesFromComputeNodeHeaders> response = BatchTestHelpers.CreateNodeFileGetPropertiesByComputeNodeResponse();
            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                ProxyModels.FileGetPropertiesFromComputeNodeOptions,
                AzureOperationHeaderResponse <ProxyModels.FileGetPropertiesFromComputeNodeHeaders> >(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);
        }