- Timestamp:
- 07/01/10 18:57:26 (15 years ago)
- Location:
- branches/HeuristicLab.Services.Authentication Prototype
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUser.cs ¶
r3948 r3992 98 98 } 99 99 100 public bool LockUser() 101 { 102 Locked = true; 103 return Locked; 104 } 105 100 106 // 101 107 // Summary: … … 105 111 // Returns: 106 112 // true if the membership user was successfully unlocked; otherwise, false. 107 public override bool UnlockUser() { 108 throw new NotImplementedException(); 113 public override bool UnlockUser() 114 { 115 Locked = false; 116 return !Locked; 109 117 } 110 118 } -
TabularUnified branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs ¶
r3977 r3992 305 305 } 306 306 307 public override bool UnlockUser(string userName) { 308 throw new NotImplementedException(); 307 public bool LockUser(string userName) 308 { 309 using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) 310 { 311 // check database connection 312 if (db == null) 313 { 314 return false; 315 } 316 try 317 { 318 // try to get user 319 HeuristicLabUser u = 320 db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == userName); 321 322 // unlock user 323 u.LockUser(); 324 db.SubmitChanges(); 325 return true; 326 } 327 catch (Exception) 328 { 329 return false; 330 } 331 } 332 } 333 334 public override bool UnlockUser(string userName) 335 { 336 using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) 337 { 338 // check database connection 339 if (db == null) 340 { 341 return false; 342 } 343 try 344 { 345 // try to get user 346 HeuristicLabUser u = 347 db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == userName); 348 349 // unlock user 350 u.UnlockUser(); 351 db.SubmitChanges(); 352 return true; 353 } 354 catch (Exception) 355 { 356 return false; 357 } 358 } 309 359 } 310 360 -
TabularUnified branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs ¶
r3977 r3992 237 237 238 238 /// <summary> 239 ///A test for LockUser 240 ///</summary> 241 [TestMethod()] 242 public void LockUserTest() 243 { 244 HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); 245 MembershipCreateStatus status; 246 HeuristicLabUser user = (HeuristicLabUser)target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status); 247 user.UnlockUser(); 248 Assert.IsFalse(user.Locked); 249 user.LockUser(); 250 Assert.IsTrue(user.Locked); 251 Assert.Inconclusive("Verify the correctness of this test method."); 252 } 253 254 /// <summary> 239 255 ///A test for UnlockUser 240 256 ///</summary> 241 257 [TestMethod()] 242 public void UnlockUserTest() { 243 HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value 244 string userName = string.Empty; // TODO: Initialize to an appropriate value 245 bool expected = false; // TODO: Initialize to an appropriate value 246 bool actual; 247 actual = target.UnlockUser(userName); 248 Assert.AreEqual(expected, actual); 249 Assert.Inconclusive("Verify the correctness of this test method."); 258 public void UnlockUserTest() 259 { 260 HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); 261 MembershipCreateStatus status; 262 HeuristicLabUser user = (HeuristicLabUser)target.CreateUser("testname", "newPassword", "testemail", "testquestion", "testanswer", true, null, out status); 263 user.LockUser(); 264 Assert.IsTrue(user.Locked); 265 user.UnlockUser(); 266 Assert.IsFalse(user.Locked); 267 Assert.Inconclusive("Verify the correctness of this test method."); 250 268 } 251 269
Note: See TracChangeset
for help on using the changeset viewer.