public void TestPrepare() { User user = new User(); user.Username = "******"; user.Password = "******"; IUserDal dal =new UserDal(); User returnedUser = dal.ValidateUser(user); prepareDto = new PrepareUserDto(); UserDto dto = prepareDto.Prepare(returnedUser); Console.Write(dto.Name); String[] mem = dto.Memberships; for (int count = 0; count < mem.Length; count++) { Console.Write(mem[count]); } for (int i = 0; i < dto.Tokens.Count; i++) { Console.WriteLine(dto.Tokens[i]); } Assert.IsNotNull(dto,"Should not be null"); }
public void TestFindById() { IUserDal uDal = new UserDal(); User user = uDal.FindById(20); Console.WriteLine(user.Name); Assert.IsNotNull(user); }
public User GetUserById(int id) { IUserDal userDal = new UserDal(); User user = userDal.FindById(id); return user; }
public User GetUser(string username, string password) { User user = new User(); user.Username = username; user.Password = password; IUserDal userDal = new UserDal(); return user; }
public IList<UserBookRequest> UserSearch(String searchString) { try { IUserDal userDal = new UserDal(); IList<UserBookRequest> returnedUserList = userDal.SearchUser(searchString); return returnedUserList; } catch (Exception e) { Console.WriteLine("Error in userService,userSearch()"); Console.Write(e.ToString()); return null; } }
public Boolean Create(User user) { try { IList<User> userlist = new List<User>(); userlist.Add(user); IUserDal userDal = new UserDal(); Boolean status = userDal.CreateNewUser(userlist); return status; } catch (Exception e) { Console.WriteLine("Error at UserService , CreateNewUser"); Console.Write(e.ToString()); return false; } }
public UserDto ValidateUser(string username, string password) { User user = new User(); user.Username = username; user.Password = password; IUserDal userdal = new UserDal(); User returnedUser = userdal.ValidateUser(user); if (returnedUser == null) { return null; } else { IPrepareUserDto prepareUserDto = new PrepareUserDto(); UserDto userdto = prepareUserDto.Prepare(returnedUser); return userdto; } }
// [TestMethod] public void TestUserDal() { UserDal uDal = new UserDal(); User user = new User(); user.Username = "******"; user.Password = "******"; User u = uDal.ValidateUser(user); IList<Membership> membership = u.Memberships; IList<Role> role = u.Roles; IList<Token> token = role[0].Tokens; Membership m = membership[0]; Role r = role[0]; Token t = token[0]; Console.WriteLine("Membership : "+m.Name); Console.WriteLine("Role : "+r.Name); Console.WriteLine("Token : "+t.Name); // Assert.AreEqual(1,uDal.Create(user)); }