public void GetUsersByName() { int countOfExpectedUsers = 1; GetAzureRemoteAppUser MockCmdlet = SetUpTestCommon <GetAzureRemoteAppUser>(); // Required parameters for this test MockCmdlet.CollectionName = collectionName; MockCmdlet.UserUpn = userName; // Setup the environment for testing this cmdlet MockObject.SetUpDefaultRemoteAppCollectionByName(remoteAppManagementClientMock, collectionName); MockObject.SetUpDefaultRemoteAppSecurityPrincipals(remoteAppManagementClientMock, collectionName, userName); MockCmdlet.ResetPipelines(); Log("Calling Get-AzureRemoteAppUser to get this user {0}.", MockCmdlet.UserUpn); MockCmdlet.ExecuteCmdlet(); if (MockCmdlet.runTime().ErrorStream.Count != 0) { Assert.True(false, String.Format("Get-AzureRemoteAppUser returned the following error {0}.", MockCmdlet.runTime().ErrorStream[0].Exception.Message ) ); } List <ConsentStatusModel> users = MockObject.ConvertList <ConsentStatusModel>(MockCmdlet.runTime().OutputPipeline); Assert.NotNull(users); Assert.True(users.Count == countOfExpectedUsers, String.Format("The expected number of users returned {0} does not match the actual {1}.", countOfExpectedUsers, users.Count ) ); Assert.True(MockObject.ContainsExpectedServicePrincipalList(MockObject.mockUsersConsents, users), "The actual result does not match the expected" ); Log("The test for Get-AzureRemoteAppUser with {0} users completed successfully.", countOfExpectedUsers); }