public void GetGroupEntry_GetEntryAndSearchForItViaSearcher_ReturnsSearchedEntry() { var directoryEntry = A.Fake <IDirectoryEntry>(); A.CallTo(() => directoryEntryAdapter.GetEntry("groupname", groupConfig, A <Func <IEntry, IDirectorySearcher> > .Ignored)).Returns(directoryEntry); var searcher = A.Fake <IDirectorySearcher>(); var searchedEntry = A.Fake <IEntry>(); A.CallTo(() => searcherFactory.CreateSearcher(directoryEntry, SearchScope.Base, groupConfig)).Returns(searcher); A.CallTo(() => searcher.FindOne(groupConfig.MembershipAttribute)).Returns(searchedEntry); var result = adapter.GetGroupEntry("groupname", true); Assert.AreSame(searchedEntry, result); }
protected virtual IDirectorySearcher CreateSearcher(IEntry entry, SearchScope searchScope) { return(searcherFactory.CreateSearcher(entry, searchScope, Config)); }
public void GetUserEntryAndLoadProperties_UserEntryLoadedFromDirectoryAndThenLoadedViaSearcher_ReturnsEntryFromSearcher() { var directoryEntry = A.Fake <IDirectoryEntry>(); var searcher = A.Fake <IDirectorySearcher>(); var entry = A.Fake <IDirectoryEntry>(); A.CallTo(() => directoryEntryAdapter.GetEntry("anyusername", ldapConfig.Users, A <Func <IEntry, IDirectorySearcher> > .Ignored)).Returns(directoryEntry); A.CallTo(() => searcherFactory.CreateSearcher(directoryEntry, SearchScope.Base, ldapConfig.Users)).Returns(searcher); A.CallTo(() => searcher.FindOne()).Returns(entry); var result = adapter.GetUserEntryAndLoadProperties("anyusername"); Assert.AreSame(entry, result); }