public void GetUsersInGroupMembership_ShouldThrowExceptionOnNullGroupName() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); target.GetUsersInGroupMembership(""); }
public void GetUsersInGroupMembership_ShouldThrowExceptionOnNullGroupNameWithCorrectDebugInformation() { IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); try { target.GetUsersInGroupMembership(""); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.ParamName == "groupName"); return; } Assert.Fail(); }
public void GetUsersInGroupMembership_ShouldReturnCorrectListOfADUser() { var expectedUser = new List <ADUser>() { 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" }, new ADUser() { Email = "*****@*****.**", DistinguishedName = "xxx,xxxxx,xxx123456789xxxxlocation,yyyy", DNSHostname = "my Host Name 2", FirstName = "Fred 2", LastName = "Blogs 2", GivenName = "Fred Blogs 2", Login = "******", ProfilePath = @"\\ServerName\SomeFolderOnServer2", SN = "sn information2", TelephoneNumber = "00 00 00 002", UserPrincipalName = "bfred2", OfficeLocation = "ASTON" } }; IMyPrincipalSearcher searcher = new FakePrincipalSearcher(); ActiveDirectoryHelper target = new ActiveDirectoryHelper(searcher); var actual = target.GetUsersInGroupMembership("group"); Assert.AreEqual(expectedUser[0].Login, actual[0].Login); Assert.AreEqual(expectedUser[0].FirstName, actual[0].FirstName); Assert.AreEqual(expectedUser[0].LastName, actual[0].LastName); Assert.AreEqual(expectedUser[0].Email, actual[0].Email); Assert.AreEqual(expectedUser[0].DistinguishedName, actual[0].DistinguishedName); Assert.AreEqual(expectedUser[0].DNSHostname, actual[0].DNSHostname); Assert.AreEqual(expectedUser[0].GivenName, actual[0].GivenName); Assert.AreEqual(expectedUser[0].ProfilePath, actual[0].ProfilePath); Assert.AreEqual(expectedUser[0].SN, actual[0].SN); Assert.AreEqual(expectedUser[0].TelephoneNumber, actual[0].TelephoneNumber); Assert.AreEqual(expectedUser[0].UserPrincipalName, actual[0].UserPrincipalName); Assert.AreEqual(expectedUser[0].OfficeLocation, actual[0].OfficeLocation); Assert.AreEqual(expectedUser[1].Login, actual[1].Login); Assert.AreEqual(expectedUser[1].FirstName, actual[1].FirstName); Assert.AreEqual(expectedUser[1].LastName, actual[1].LastName); Assert.AreEqual(expectedUser[1].Email, actual[1].Email); Assert.AreEqual(expectedUser[1].DistinguishedName, actual[1].DistinguishedName); Assert.AreEqual(expectedUser[1].DNSHostname, actual[1].DNSHostname); Assert.AreEqual(expectedUser[1].GivenName, actual[1].GivenName); Assert.AreEqual(expectedUser[1].ProfilePath, actual[1].ProfilePath); Assert.AreEqual(expectedUser[1].SN, actual[1].SN); Assert.AreEqual(expectedUser[1].TelephoneNumber, actual[1].TelephoneNumber); Assert.AreEqual(expectedUser[1].UserPrincipalName, actual[1].UserPrincipalName); Assert.AreEqual(expectedUser[1].OfficeLocation, actual[1].OfficeLocation); }