Unit tests for code accessing ActiveDirectory

前端 未结 2 1200
梦毁少年i
梦毁少年i 2021-02-20 04:49

What\'s the best way to unit test an application accessing the ActiveDirectory and/or mock the dependencies to the AD?

All the required types such as DirectorySear

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-20 05:17

    If they're not mockable (don't have MSDN at hand, so I can't really tell), you can always abstract them behind an IDirectorySearcher and IDirectoryEntry and mock these. With this approach you can simplify the API by tailoring it specifically to suit your needs.

提交回复
热议问题