Пример #1
0
        public void ListBatchNodeAgentSkusParametersTest()
        {
            BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();

            cmdlet.BatchContext = context;

            string[] idsOfNodeAgentSkus = new[] { "batch.node.centos 7", "batch.node.debian 8", "batch.node.opensuse 13.2" };

            // Don't go to the service on an Get NodeAgentSkus call
            AzureOperationResponse <IPage <ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> response =
                BatchTestHelpers.CreateNodeAgentSkuResponse(idsOfNodeAgentSkus);

            RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor <
                ProxyModels.AccountListNodeAgentSkusOptions,
                AzureOperationResponse <IPage <ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> >(responseToUse: response);

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

            // Setup the cmdlet to write pipeline output to a list that can be examined later
            List <PSNodeAgentSku> pipeline = new List <PSNodeAgentSku>();

            commandRuntimeMock.Setup(r =>
                                     r.WriteObject(It.IsAny <PSNodeAgentSku>()))
            .Callback <object>(p => pipeline.Add((PSNodeAgentSku)p));

            // Verify no exceptions when required parameter is set
            cmdlet.ExecuteCmdlet();

            Assert.Equal(3, pipeline.Count);
            int nodeAgentCount = 0;

            foreach (PSNodeAgentSku p in pipeline)
            {
                Assert.True(idsOfNodeAgentSkus.Contains(p.Id));
                nodeAgentCount++;
            }
            Assert.Equal(idsOfNodeAgentSkus.Length, nodeAgentCount);
        }