[TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing public void EndToEndRemovePowerBIWorkspaceUserOrganizationScope() { using (var ps = System.Management.Automation.PowerShell.Create()) { // Arrange ProfileTestUtilities.ConnectToPowerBI(ps); var workspace = WorkspacesTestUtilities.GetFirstWorkspaceWithUsersInOrganization(ps); WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace); var emailAddress = "*****@*****.**"; var parameters = new Dictionary <string, object>() { { nameof(RemovePowerBIWorkspaceUser.Scope), PowerBIUserScope.Organization }, { nameof(RemovePowerBIWorkspaceUser.Id), workspace.Id }, { nameof(RemovePowerBIWorkspaceUser.UserPrincipalName), emailAddress }, }; ps.AddCommand(Cmdlet).AddParameters(parameters); // Act var results = ps.Invoke(); // Assert TestUtilities.AssertNoCmdletErrors(ps); Assert.IsNotNull(results); var updatedWorkspace = WorkspacesTestUtilities.GetWorkspace(ps, PowerBIUserScope.Organization, workspace.Id); Assert.IsFalse(updatedWorkspace.Users.Any(x => x.UserPrincipalName.Equals(emailAddress, StringComparison.OrdinalIgnoreCase))); } }
[TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing public void EndToEndGetWorkspacesOrganizationScopeAndUser() { /* * Test requires a preview workspace (v2) to exist and login as an administrator */ using (var ps = System.Management.Automation.PowerShell.Create()) { // Arrange ProfileTestUtilities.ConnectToPowerBI(ps); var workspace = WorkspacesTestUtilities.GetFirstWorkspaceWithUsersInOrganization(ps); WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace); var userEmailAddress = workspace.Users.FirstOrDefault().UserPrincipalName; var parameters = new Dictionary <string, object>() { { nameof(GetPowerBIWorkspace.Scope), PowerBIUserScope.Organization }, { nameof(GetPowerBIWorkspace.User), userEmailAddress } }; ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo).AddParameters(parameters); // Act var results = ps.Invoke(); // Assert TestUtilities.AssertNoCmdletErrors(ps); Assert.IsNotNull(results); Assert.IsTrue(results.Any()); // Arrange ps.Commands.Clear(); parameters[nameof(GetPowerBIWorkspace.User)] = TestUtilities.GetRandomString(); ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo).AddParameters(parameters); // Act results = ps.Invoke(); // Assert TestUtilities.AssertNoCmdletErrors(ps); Assert.IsNotNull(results); Assert.IsFalse(results.Any()); } }
[TestCategory("SkipWhenLiveUnitTesting")] // Ignore for Live Unit Testing public void EndToEndGetWorkspacesAllAndOrganizationScopeAndUser() { /* * Test requires at least one workspace (group or preview workspace) with the given user and login as an administrator */ using (var ps = System.Management.Automation.PowerShell.Create()) { // Arrange ProfileTestUtilities.ConnectToPowerBI(ps); var workspace = WorkspacesTestUtilities.GetFirstWorkspaceWithUsersInOrganization(ps); WorkspacesTestUtilities.AssertShouldContinueOrganizationTest(workspace); var userEmailAddress = workspace.Users.FirstOrDefault().UserPrincipalName; var parameters = new Dictionary <string, object>() { { nameof(GetPowerBIWorkspace.Scope), PowerBIUserScope.Organization }, { nameof(GetPowerBIWorkspace.All), true }, { nameof(GetPowerBIWorkspace.User), userEmailAddress } }; ps.AddCommand(WorkspacesTestUtilities.GetPowerBIWorkspaceCmdletInfo) .AddParameters(parameters); // Act var results = ps.Invoke(); // Assert TestUtilities.AssertNoCmdletErrors(ps); Assert.IsNotNull(results); if (!results.Any()) { Assert.Inconclusive("No workspaces returned. Verify you have workspaces with the specified user in your organization."); } Assert.IsNotNull(results.Select(x => (Workspace)x.BaseObject).FirstOrDefault(w => w.Id == workspace.Id)); } }