Exemple #1
0
        public void RestorePowerBIWorkspaceOrganizationScope_IdParameterSet()
        {
            // Arrange
            var workspaceId    = Guid.NewGuid();
            var restoreRequest = new WorkspaceRestoreRequest {
                RestoredName = "Undeleted", AdminUserPrincipalName = "*****@*****.**"
            };
            var expectedResponse = new object();
            var client           = new Mock <IPowerBIApiClient>();

            client.Setup(x => x.Workspaces
                         .RestoreDeletedWorkspaceAsAdmin(workspaceId, It.Is <WorkspaceRestoreRequest>(r => r.RestoredName == restoreRequest.RestoredName && r.AdminUserPrincipalName == restoreRequest.AdminUserPrincipalName)))
            .Returns(expectedResponse);
            var initFactory = new TestPowerBICmdletInitFactory(client.Object);
            var cmdlet      = new RestorePowerBIWorkspace(initFactory)
            {
                Scope                  = PowerBIUserScope.Organization,
                Id                     = workspaceId,
                RestoredName           = restoreRequest.RestoredName,
                AdminUserPrincipalName = restoreRequest.AdminUserPrincipalName,
                ParameterSet           = "Id",
            };

            // Act
            cmdlet.InvokePowerBICmdlet();

            // Assert
            TestUtilities.AssertExpectedUnitTestResults(expectedResponse, client, initFactory);
        }
        public override void ExecuteCmdlet()
        {
            var workspaceId    = this.ParameterSet.Equals(IdParameterSetName) ? this.Id : this.Workspace.Id;
            var restoreRequest = new WorkspaceRestoreRequest {
                RestoredName = this.RestoredName, AdminUserPrincipalName = this.AdminUserPrincipalName
            };

            using (var client = this.CreateClient())
            {
                var result = client.Workspaces.RestoreDeletedWorkspaceAsAdmin(workspaceId, restoreRequest);
                this.Logger.WriteObject(result, true);
            }
        }