Changeset 3977
- Timestamp:
- 06/29/10 19:45:09 (14 years ago)
- Location:
- branches/HeuristicLab.Services.Authentication Prototype
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs
r3966 r3977 11 11 using Persistence; 12 12 13 13 14 namespace Service.Provider { 14 15 class HeuristicLabMembershipProvider : MembershipProvider { … … 249 250 } 250 251 252 // not for production use - fab and dkhan are currently working on that 251 253 public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) { 252 throw new NotImplementedException(); 254 totalRecords = 0; 255 using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) { 256 if (db == null) { 257 totalRecords = 0; 258 return new MembershipUserCollection(); 259 } 260 261 // bail out if there are no records 262 if (0 == (totalRecords = db.HeuristicLabUsers.Count<HeuristicLabUser>())) return new MembershipUserCollection(); 263 264 MembershipUserCollection userCollection = new MembershipUserCollection(); 265 int skip = (pageIndex == 0) ? 0 : (pageIndex * pageSize) - 1; 266 267 var users = from u in db.HeuristicLabUsers select u; 268 269 foreach (HeuristicLabUser u in users) { 270 271 // this leads to a npe 272 if (u != null) { 273 userCollection.Add(u); 274 } 275 } 276 return userCollection; 277 } 253 278 } 254 279 -
branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs
r3974 r3977 339 339 /// <summary> 340 340 ///A test for GetAllUsers 341 /// 342 /// work in progress 341 343 ///</summary> 342 344 [TestMethod()] 343 345 public void GetAllUsersTest() { 344 HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); // TODO: Initialize to an appropriate value 345 int pageIndex = 0; // TODO: Initialize to an appropriate value 346 int pageSize = 0; // TODO: Initialize to an appropriate value 347 int totalRecords = 0; // TODO: Initialize to an appropriate value 348 int totalRecordsExpected = 0; // TODO: Initialize to an appropriate value 349 MembershipUserCollection expected = null; // TODO: Initialize to an appropriate value 350 MembershipUserCollection actual; 351 actual = target.GetAllUsers(pageIndex, pageSize, out totalRecords); 352 Assert.AreEqual(totalRecordsExpected, totalRecords); 353 Assert.AreEqual(expected, actual); 354 Assert.Inconclusive("Verify the correctness of this test method."); 346 HeuristicLabMembershipProvider target = new HeuristicLabMembershipProvider(); 347 MembershipCreateStatus status; 348 int totalRecords; 349 350 // Create some users 351 for (int i = 0; i < 50; i++) 352 { 353 target.CreateUser("User " + i, "newPassword " + i, "testemail " + i, "testquestion " + i, "testanswer " + i, true, null, out status); 354 } 355 356 MembershipUserCollection users = target.GetAllUsers(0, 5, out totalRecords); 357 358 int j = 0; 359 foreach (HeuristicLabUser user in users) { 360 Assert.Equals("User " + j, user.UserName); 361 j++; 362 } 363 364 355 365 } 356 366
Note: See TracChangeset
for help on using the changeset viewer.