Reputation: 991
I'm doing some unit testing and I need to create a test collection of the type PrincipalSearchResult<Principal>
. This collection is normally returned when you use the method call UserPrincipal.GetAuthorizationGroups()
.
This type is part of the System.DirectoryServices.AccountManagement
namepsace which houses code for querying Microsoft's Active Directory.
If I try to simply create a new collection like such, I get an error:
PrincipalSearchResult<Principal> restResult = new PrincipalSearchResult<Principal>();
Error message:
PrincipalSearchResult<Principal>
does not contain a constructor that takes 0 arguments.
But I'm not getting any Intellisense when newing-up the collection that indicates what parameters to pass the constructor.
How can I create and populate this type?
Upvotes: 1
Views: 627
Reputation: 991
Following suggestions provided in comments, I simply created a wrapper method that returned the PrincipalSearchResult<Principal>
type cast to IEnumerable<Principal>
for mocking.
Upvotes: 1