public void GetPersistedScriptAction()
        {
            var persistedScripts = new List <RuntimeScriptAction> {
                scriptActionDetail
            };
            var getCmdlet = new GetAzureHDInsightPersistedScriptAction
            {
                CommandRuntime            = commandRuntimeMock.Object,
                HDInsightManagementClient = hdinsightManagementMock.Object,
                ClusterName       = ClusterName,
                Name              = scriptActionDetail.Name,
                ResourceGroupName = ResourceGroupName
            };

            hdinsightManagementMock.Setup(c => c.ListPersistedScripts(ResourceGroupName, ClusterName))
            .Returns(new ClusterListPersistedScriptActionsResponse
            {
                PersistedScriptActions = persistedScripts,
                StatusCode             = HttpStatusCode.OK,
                RequestId = null
            })
            .Verifiable();

            getCmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(f => f.WriteObject(
                                          It.Is <IList <AzureHDInsightRuntimeScriptAction> >(
                                              scripts =>
                                              CompareScriptActions(scripts.Single(), new AzureHDInsightRuntimeScriptAction(scriptActionDetail))), true));
            hdinsightManagementMock.VerifyAll();
            hdinsightManagementMock.Verify(c => c.ListPersistedScripts(ResourceGroupName, ClusterName),
                                           Times.Once);
        }
Ejemplo n.º 2
0
        public void GetPersistedScriptAction()
        {
            var persistedScripts = new List<RuntimeScriptAction> { scriptActionDetail };
            var getCmdlet = new GetAzureHDInsightPersistedScriptAction
            {
                CommandRuntime = commandRuntimeMock.Object,
                HDInsightManagementClient = hdinsightManagementMock.Object,
                ClusterName = ClusterName,
                Name = scriptActionDetail.Name,
                ResourceGroupName = ResourceGroupName
            };

            hdinsightManagementMock.Setup(c => c.ListPersistedScripts(ResourceGroupName, ClusterName))
                .Returns(new ClusterListPersistedScriptActionsResponse
                {
                    PersistedScriptActions = persistedScripts,
                    StatusCode = HttpStatusCode.OK,
                    RequestId = null
                })
                .Verifiable();

            getCmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(f => f.WriteObject(
                It.Is<IList<AzureHDInsightRuntimeScriptAction>>(
                    scripts =>
                        CompareScriptActions(scripts.Single(), new AzureHDInsightRuntimeScriptAction(scriptActionDetail))), true));
            hdinsightManagementMock.VerifyAll();
            hdinsightManagementMock.Verify(c => c.ListPersistedScripts(ResourceGroupName, ClusterName),
                Times.Once);
        }