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

            cmdlet.BatchContext    = context;
            cmdlet.PoolName        = null;
            cmdlet.VMName          = null;
            cmdlet.VM              = null;
            cmdlet.DestinationPath = null;

            // Don't go to the service on a GetTVMRDPFile call
            YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
            {
                if (request is GetTVMRDPFileRequest)
                {
                    GetTVMRDPFileResponse response = new GetTVMRDPFileResponse();
                    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.PoolName = "pool";
                cmdlet.VMName   = "vm1";

                // Verify no exceptions occur
                cmdlet.ExecuteCmdlet();
            }
        }
コード例 #2
0
        public void GetBatchRDPFileParametersTest()
        {
            // Setup cmdlet without required parameters
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
            cmdlet.BatchContext = context;
            cmdlet.PoolName = null;
            cmdlet.VMName = null;
            cmdlet.VM = null;
            cmdlet.DestinationPath = null;

            // Don't go to the service on a GetTVMRDPFile call
            YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
            {
                if (request is GetTVMRDPFileRequest)
                {
                    GetTVMRDPFileResponse response = new GetTVMRDPFileResponse();
                    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.PoolName = "pool";
                cmdlet.VMName = "vm1";

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