Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to integrate test this method?
    primarykey
    data
    text
    <p>Hi I am writing integration tests.</p> <p>My method is </p> <pre><code>public IList&lt;string&gt; GetUsersRecursively(string groupName) { using (var context = GetPrincipalContext()) { using (var group = GroupPrincipal.FindByIdentity(context, groupName)) { using (var users = group.GetMembers(true)) { return (from user in users orderby user.SamAccountName select user.SamAccountName ).ToList(); }; // recursively enumerate } } // return results; } </code></pre> <p>And Test I have written is </p> <pre><code> [Test] public void GetUsersRecursively() { // Arrange var target = this.provider; string groupName = "CAS_Branch_Manager"; string expectedUsername = "test.branchmanager"; // Act var result = this.provider.GetUsersRecursively(groupName); // Assert Assert.NotNull(result); CollectionAssert.Contains(result, expectedUsername); } </code></pre> <p>But by running it on resharper it shows error that </p> <p>System.DirectoryServices.AccountManagement.PrincipalServerDownException : The server could not be contacted. ----> System.DirectoryServices.Protocols.LdapException : The LDAP server is unavailable.</p> <p>Then to handle exception I have written as</p> <pre><code> [Test] [ExpectedException(typeof(PrincipalServerDownException ))] public void GetUsersRecursively() { // Arrange var target = this.provider; string groupName = "CAS_Branch_Manager"; string expectedUsername = "test.branchmanager"; // Act var result = this.provider.GetUsersRecursively(groupName); // Assert Assert.NotNull(result); CollectionAssert.Contains(result, expectedUsername); } </code></pre> <p>But now PrincipalServerDownException showing error as cannot resolve symbol "PrincipalServerDownException". HOw to solve it ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload