예제 #1
0
        public void GetADGroupUserAttributes_OnValidCall_ConfirmResult()
        {
            // Arrange
            ShimDirectoryEntry.AllInstances.RefreshCacheStringArray = (_, __) => _deRefreshCacheCalled = true;

            // Act
            var result = _testObj.GetADGroupUserAttributes(DummyString, DummyString);

            // Assert
            this.ShouldSatisfyAllConditions(
                () => _deRefreshCacheCalled.ShouldBeTrue(),
                () => result.ShouldNotBeNull());
        }
        public void GetADGroupUserAttributes_Called_DirectoryDisposed()
        {
            // Arrange
            var directoryShims = DirectoryShims.ShimDirectoryCalls();

            ShimDirectorySearcher.ConstructorDirectoryEntryString = (instance, _, __) =>
            {
                new ShimDirectorySearcher(instance)
                {
                    FindOne = () => directoryShims.SearchResultShim
                };
            };
            var table = new DataTable();

            table.Columns.Add(ColumnSid);
            _adSyncObject.SetField("_adUsers", table);

            // Act
            var result = _adSync.GetADGroupUserAttributes(string.Empty, string.Empty);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(SamplePropertyValue.ToLower(), result.FirstOrDefault());
            Assert.IsTrue(directoryShims.DirectorySearchersDisposed.Any());
            Assert.AreEqual(2, directoryShims.DirectoryEntriesDisposed.Count);
        }