I don't think that you'll be able to mock or create an instance of PropertyCollection
. There are ways of overcoming this, but they require you to convert your derived wrapper class to be more of an actual wrapper, encapsulating a DirectoryEntry
object and providing accessors, not extending it. Once you've done that, you have these options:
- Define the return type of the
Properties
property as one of the underlying collection types thatPropertyCollection
implements (IDictionary
,ICollection
orIEnumerable
), if that is sufficient for your needs - Create an encapsulating wrapper class with an interface for
PropertyCollection
, and create a new one to wrapdirectoryEntry.Properties
each time theProperties
accessor is called - Create methods on
IDirectoryEntry
/DirectoryEntryWrapper
that return what you need without having to expose aProperties
property
1 might be fine as a workaround, if you're OK accessing the properties through one of the underlying collection types. 2 will require you to implement every method and property of PropertiesCollection
in the wrapper, calling through to the encapsulated object underneath, but would be the most flexible. The easiest (but least flexible) is 3.