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

            cmdlet.BatchContext    = context;
            cmdlet.WorkItemName    = null;
            cmdlet.JobName         = null;
            cmdlet.TaskName        = null;
            cmdlet.Name            = null;
            cmdlet.InputObject     = null;
            cmdlet.DestinationPath = null;

            string fileName = "stdout.txt";

            // Don't hit the file system during unit tests
            cmdlet.Stream = new MemoryStream();

            // Don't go to the service on a GetTaskFile call or GetTaskFileProperties call
            YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
            {
                if (request is GetTaskFilePropertiesRequest)
                {
                    GetTaskFilePropertiesResponse response = BatchTestHelpers.CreateGetTaskFilePropertiesResponse(fileName);
                    Task <object> task = Task <object> .Factory.StartNew(() => { return(response); });
                    return(task);
                }
                if (request is GetTaskFileRequest)
                {
                    GetTaskFileResponse response = new GetTaskFileResponse();
                    Task <object> task           = Task <object> .Factory.StartNew(() => { return(response); });
                    return(task);
                }
                return(null);
            });

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

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

            // Fill required Task file details
            cmdlet.WorkItemName = "workItem";
            cmdlet.JobName      = "job-0000000001";
            cmdlet.TaskName     = "task";
            cmdlet.Name         = fileName;

            try
            {
                // Verify no exceptions occur
                cmdlet.ExecuteCmdlet();
            }
            finally
            {
                cmdlet.Stream.Dispose();
            }
        }
        public void GetBatchTaskFileParametersTest()
        {
            // Setup cmdlet without required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
            cmdlet.BatchContext = context;
            cmdlet.WorkItemName = null;
            cmdlet.JobName = null;
            cmdlet.TaskName = null;
            cmdlet.Name = null;
            cmdlet.InputObject = null;
            cmdlet.DestinationPath = null;

            string fileName = "stdout.txt";

            // Don't go to the service on a GetTaskFile call or GetTaskFileProperties call
            YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
            {
                if (request is GetTaskFilePropertiesRequest)
                {
                    GetTaskFilePropertiesResponse response = BatchTestHelpers.CreateGetTaskFilePropertiesResponse(fileName);
                    Task<object> task = Task<object>.Factory.StartNew(() => { return response; });
                    return task;
                }
                if (request is GetTaskFileRequest)
                {
                    GetTaskFileResponse response = new GetTaskFileResponse();
                    Task<object> task = Task<object>.Factory.StartNew(() => { return response; });
                    return task;
                }
                return null;
            });
            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 Task file details
                cmdlet.WorkItemName = "workItem";
                cmdlet.JobName = "job-0000000001";
                cmdlet.TaskName = "task";
                cmdlet.Name = fileName;

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