Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/10 02:20:51 (14 years ago)
Author:
dkahn
Message:

#1061 Extended tests for GetAllUsers() and added FindUsersByEmail() and FindUsersByName() plus unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs

    r4007 r4008  
    242242
    243243
    244 
     244    /// <summary>
     245    /// Returns a paged collection of users that match a given e-mail address
     246    /// TODO: Return a sorted result set
     247    /// </summary>
     248    /// <param name="emailToMatch"></param>
     249    /// <param name="pageIndex"></param>
     250    /// <param name="pageSize"></param>
     251    /// <param name="totalRecords"></param>
     252    /// <returns></returns>
    245253    public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) {
    246       throw new NotImplementedException();
    247       totalRecords = 0;
    248       using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
    249         // don't test db - throw an exception instead if something wents wrong
    250         // bail out if there are no records
    251         if (0 == (totalRecords = db.HeuristicLabUsers.Count<HeuristicLabUser>())) return new MembershipUserCollection();
    252 
    253         MembershipUserCollection userCollection = new MembershipUserCollection();
    254 
    255       }
    256     }
    257 
    258 
     254      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     255        IQueryable<HeuristicLabUser> users = (from u in db.HeuristicLabUsers where u.Email == emailToMatch select u);
     256        return PagedCollection(users, pageIndex, pageSize, out totalRecords);
     257      }
     258    }
     259
     260    /// <summary>
     261    /// Returns a paged collection of users that match a given username
     262    /// TODO: Return a sorted result set
     263    /// </summary>
     264    /// <param name="usernameToMatch"></param>
     265    /// <param name="pageIndex"></param>
     266    /// <param name="pageSize"></param>
     267    /// <param name="totalRecords"></param>
     268    /// <returns></returns>
    259269    public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) {
    260       throw new NotImplementedException();
    261     }
    262 
     270      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     271        IQueryable<HeuristicLabUser> users = (from u in db.HeuristicLabUsers where u.UserName == usernameToMatch select u);
     272        return PagedCollection(users, pageIndex, pageSize, out totalRecords);
     273      }
     274     
     275    }
     276
     277    /// <summary>
     278    /// Returns a paged collection of all users
     279    /// TODO: Return a sorted result set
     280    /// </summary>
     281    /// <param name="pageIndex"></param>
     282    /// <param name="pageSize"></param>
     283    /// <param name="totalRecords"></param>
     284    /// <returns></returns>
    263285    public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) {
    264286      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     
    268290        return PagedCollection(users, pageIndex, pageSize, out totalRecords);
    269291      }
     292     
    270293    }
    271294
Note: See TracChangeset for help on using the changeset viewer.