Example #1
0
        public void SearchUserByLogin_ShouldThrowExceptionOnNullAccountName()
        {
            IMyPrincipalSearcher  searcher = new FakePrincipalSearcher();
            ActiveDirectoryHelper target   = new ActiveDirectoryHelper(searcher);

            ADUser actual = target.SearchUserByLogin("");
        }
Example #2
0
        public void SearchUserByLoginTest_ShouldReturnCorrectADUser()
        {
            ADUser expectedUser = new ADUser()
            {
                Email             = "*****@*****.**",
                DistinguishedName = "xxx,xxxxx,xxx123456789xxxxlocation,yyyy",
                DNSHostname       = "my Host Name",
                FirstName         = "Fred",
                LastName          = "Blogs",
                GivenName         = "Fred Blogs",
                Login             = "******",
                ProfilePath       = @"\\ServerName\SomeFolderOnServer",
                SN = "sn information",
                TelephoneNumber   = "00 00 00 000",
                UserPrincipalName = "bfred",
                OfficeLocation    = "ASTON"
            };
            IMyPrincipalSearcher  searcher = new FakePrincipalSearcher();
            ActiveDirectoryHelper target   = new ActiveDirectoryHelper(searcher);

            ADUser actual = target.SearchUserByLogin("77777777");

            Assert.AreEqual(expectedUser.Email, actual.Email);
            Assert.AreEqual(expectedUser.DistinguishedName, actual.DistinguishedName);
            Assert.AreEqual(expectedUser.DNSHostname, actual.DNSHostname);
            Assert.AreEqual(expectedUser.FirstName, actual.FirstName);
            Assert.AreEqual(expectedUser.LastName, actual.LastName);
            Assert.AreEqual(expectedUser.GivenName, actual.GivenName);
            Assert.AreEqual(expectedUser.Login, actual.Login);
            Assert.AreEqual(expectedUser.ProfilePath, actual.ProfilePath);
            Assert.AreEqual(expectedUser.SN, actual.SN);
            Assert.AreEqual(expectedUser.TelephoneNumber, actual.TelephoneNumber);
            Assert.AreEqual(expectedUser.UserPrincipalName, actual.UserPrincipalName);
            Assert.AreEqual(expectedUser.OfficeLocation, actual.OfficeLocation);
        }
Example #3
0
        public void SearchUserByLogin_ShouldThrowExceptionOnNullAccountNameWithCorrectDebugInformation()
        {
            IMyPrincipalSearcher  searcher = new FakePrincipalSearcher();
            ActiveDirectoryHelper target   = new ActiveDirectoryHelper(searcher);

            try
            {
                ADUser actual = target.SearchUserByLogin("");
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.ParamName == "samAccountName");
                return;
            }

            Assert.Fail();
        }