- Timestamp:
- 07/07/10 01:03:47 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs
r4004 r4006 89 89 [TestMethod()] 90 90 public void PasswordStrengthRegularExpressionTest() { 91 MembershipProvider target = Membership.Provider; 91 MembershipProvider target = Membership.Provider; 92 92 string actual; 93 93 actual = target.PasswordStrengthRegularExpression; … … 100 100 [TestMethod()] 101 101 public void PasswordFormatTest() { 102 MembershipProvider target = Membership.Provider; 102 MembershipProvider target = Membership.Provider; 103 103 MembershipPasswordFormat actual; 104 104 actual = target.PasswordFormat; … … 123 123 public void MinRequiredPasswordLengthTest() { 124 124 MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value 125 126 MembershipCreateStatus status; 127 target.CreateUser("username", "", "mail", "question", "answer", true, null, out status);125 126 MembershipCreateStatus status; 127 target.CreateUser("username", "", "mail", "question", "answer", true, null, out status); 128 128 Assert.AreEqual(status, MembershipCreateStatus.InvalidPassword); 129 129 target.CreateUser("username", "testusername", "mail", "question", "answer", true, null, out status); … … 149 149 [TestMethod()] 150 150 public void MaxInvalidPasswordAttemptsTest() { 151 MembershipProvider target = Membership.Provider; 151 MembershipProvider target = Membership.Provider; 152 152 int actual; 153 153 actual = target.MaxInvalidPasswordAttempts; … … 160 160 [TestMethod()] 161 161 public void EnablePasswordRetrievalTest() { 162 MembershipProvider target = Membership.Provider; 162 MembershipProvider target = Membership.Provider; 163 163 bool actual; 164 164 actual = target.EnablePasswordRetrieval; … … 182 182 [TestMethod()] 183 183 public void ApplicationNameTest() { 184 MembershipProvider target = Membership.Provider; 184 MembershipProvider target = Membership.Provider; 185 185 string expected = string.Empty; // TODO: Initialize to an appropriate value 186 186 string actual; … … 196 196 [TestMethod()] 197 197 public void ValidateUserTest() { 198 MembershipProvider target = Membership.Provider; 198 MembershipProvider target = Membership.Provider; 199 199 MembershipCreateStatus status; 200 200 target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status); … … 207 207 [TestMethod()] 208 208 public void ValidateUserTestEncrypted() { 209 MembershipProvider target = Membership.Provider; 209 MembershipProvider target = Membership.Provider; 210 210 NameValueCollection config = new NameValueCollection(); 211 211 config.Add("passwordFormat", "Encrypted"); … … 241 241 ///</summary> 242 242 [TestMethod()] 243 public void LockUserTest() 244 { 245 MembershipProvider target = Membership.Provider; 246 MembershipCreateStatus status; 247 Persistence.HeuristicLabMembershipUser user = (Persistence.HeuristicLabMembershipUser)target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status); 248 user.UnlockUser(); 249 HeuristicLabUser dbUser = db.HeuristicLabUsers.Single(u => u.UserName == "testname"); 250 Assert.IsFalse(dbUser.Locked); 251 Assert.IsTrue(dbUser.Locked); 252 253 } 254 255 243 public void LockUserTest() { 244 MembershipProvider target = Membership.Provider; 245 MembershipCreateStatus status; 246 Persistence.HeuristicLabMembershipUser user = (Persistence.HeuristicLabMembershipUser)target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status); 247 user.UnlockUser(); 248 HeuristicLabUser dbUser = db.HeuristicLabUsers.Single(u => u.UserName == "testname"); 249 Assert.IsFalse(dbUser.Locked); 250 Assert.IsTrue(dbUser.Locked); 251 252 } 253 254 256 255 257 256 /// <summary> … … 351 350 MembershipCreateStatus status; 352 351 int totalRecords; 352 int numberOfUsers = 13; 353 int pageSize = 5; 353 354 354 355 // Create some users 355 for (int i = 0; i < 50; i++)356 {357 target.CreateUser("User " + i, "newPassword " + i, "testemail " + i, "testquestion " + i, "testanswer " + i, true, null, out status);358 } 359 360 MembershipUserCollection users = target.GetAllUsers( 0, 5, out totalRecords);361 362 int j = 0;356 for (int i = 0; i < numberOfUsers; i++) { 357 target.CreateUser("User " + i, "newPassword " + i, "testemail " + i, "testquestion " + i, "testanswer " + i, true, null, out status); 358 } 359 360 // basic proof as in http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.getallusers.aspx 361 MembershipUserCollection users = target.GetAllUsers(1, pageSize, out totalRecords); 362 HeuristicLabMembershipUser firstUser = null; 363 HeuristicLabMembershipUser lastUser = null; 363 364 foreach (HeuristicLabMembershipUser user in users) { 364 Assert.Equals("User " + j, user.UserName); 365 j++; 366 } 367 368 365 if (firstUser == null) { 366 firstUser = user; 367 } 368 lastUser = user; 369 } 370 Assert.AreEqual("User 5", firstUser.UserName); 371 Assert.AreEqual("User 9", lastUser.UserName); 372 373 374 // simulate paging and make sure that a valid empty collection is returned in the end 375 int pageIndex = 0; 376 while ((users = target.GetAllUsers(pageIndex, pageSize, out totalRecords)).Count != 0) { 377 378 // check that totalRecords constantly equals the number of created users 379 Assert.AreEqual(numberOfUsers, totalRecords); 380 381 int j = pageIndex * pageSize; 382 foreach (HeuristicLabMembershipUser user in users) { 383 Assert.AreEqual("User " + j, user.UserName); 384 j++; 385 } 386 pageIndex++; 387 } 388 389 // Make sure that we ended up at the last page 390 Assert.AreEqual(3, pageIndex); 369 391 } 370 392 … … 497 519 } 498 520 499 521 500 522 [TestMethod()] 501 523 public void NoDuplicateUserNameTest() {
Note: See TracChangeset
for help on using the changeset viewer.