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

            cmdlet.BatchContext = context;

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

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

            cmdlet.ThumbprintAlgorithm = "sha1";

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

            cmdlet.Thumbprint = "123456789";

            // Don't go to the service on a Delete Certificate call
            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <CertificateDeleteOptions, AzureOperationHeaderResponse <CertificateDeleteHeaders> >();

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

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