Microsoft.MetadirectoryServices.Utils how to use RRS feed

  • Question

  • Hi,

    I'm trying to create some unit tests for a Rules Extensions Code.

    Since the Utils class is a static class, I was expecting to be able to use it for Microsoft.MetadirectoryServices.Utils.FindMVEntries

    but it throws a NullReferenceException (Although it responds successfully to  Microsoft.MetadirectoryServices.Utils.ExtensionsDirectory method call)

    How can I use the Utils class on my unit tests?

    Many thanks,


    Monday, August 5, 2019 6:51 PM

All replies

  • Hi,

    This class cannot be used externally

    Patrick Layani

    • Proposed as answer by Leo Erlandsson Tuesday, August 13, 2019 12:20 PM
    Tuesday, August 13, 2019 11:53 AM
  • Hi Junidev, I've done some similar work to try to be able to unit test Rules Extensions. There's nothing in utils that will help you to unit test. What you need is some way to instantiate CSEntry and MVEntry objects in your testing framework so that you can pass them to your rules extension methods. The problem is that CSEntry and MVEntry are abstract classes. I've gotten around this by simply inheriting from CSEntry and MVEntry and implementing all of their methods. There's a fair few layers you have to implement all the way down to the values themselves but it doesn't take too long. It may not be worth the effort. You can really only test Sync Rule Extensions where you have an MVEntry and CSEntry at the start and at the end. Provisioning rules can't really be tested as far as I can see, since the Provision method will create the CSEntry objects, you don't have a reference to it to test afterwards.

    • Edited by Dan_Walters Tuesday, September 24, 2019 3:02 AM
    Tuesday, September 24, 2019 3:02 AM