public void ActivateAccountTest() { IUserService accountSrv = new UserService(); UserAppService target = new UserAppService(accountSrv); using (UserRepository repository = new UserRepository()) { Guid accountId = new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"); var account = repository.Get(accountId); string activationCode = account.ActivationCode; target.ActivateAccount(accountId, activationCode); repository.Refresh(account); Assert.AreEqual(account.IsActive, true); } }
public void ChangeAchievementTest() { IUserService accountSrv = new UserService(); UserAppService target = new UserAppService(accountSrv); AccountDTO account_dto = new AccountDTO() { AccountName = "zhangsan", Coins = 80, Email = "*****@*****.**", Gender = true, Id = new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"), IdentityCardNumber = "310123199009091234", Name = "张三", Score = 600, SpecialityType = "理科", Year = DateTime.Parse("2012-09-09"), City = "上海市", Province = "上海市" }; target.ChangeAchievement(account_dto); Assert.AreEqual(1, 1); }
public UserController() { userService = new UserAppService(); regionService = new RegionAppService(); universityService = new UniversityAppService(); }
public void ResetPasswordTest() { IUserService accountSrv = new UserService(); UserAppService target = new UserAppService(accountSrv); Guid accountId = new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"); UserRepository accountRepository = new UserRepository(); var account = accountRepository.Get(accountId); var password = account.Password; target.ResetPassword(accountId, "*****@*****.**"); accountRepository.Refresh(account); Assert.AreNotEqual(account.Password, password); }
public void RegisterTest() { IUserService accountSrv = new UserService(); UserAppService target = new UserAppService(accountSrv); using (UserRepository accountRepository = new UserRepository()) { var accounts = accountRepository.GetFiltered(a => a.AccountName == "zhangsan"); if (accounts != null && accounts.ToList<User>().Count > 0) { var existedAccount = accounts.Single<User> (a => a.AccountName == "zhangsan"); if (existedAccount != null) { accountRepository.Remove(existedAccount); accountRepository.Commit(); } } var accountAdd = User.CreateAccount(new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"), "zhangsan", "123456", "*****@*****.**", 120, false, "310123199009091244", "张三", "", true, false); target.Register(accountAdd); var accountInRepository = accountRepository.Get(accountAdd.Id); Assert.AreEqual(accountInRepository.AccountName, accountAdd.AccountName); } }
public void RechargeTest() { IUserService accountSrv = new UserService(); UserAppService target = new UserAppService(accountSrv); UserRepository accountRepository = new UserRepository(); int original = 0; Guid accountId = new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"); var account = accountRepository.Get(accountId); original = account.Coins; int coins = 10; target.Recharge(account.Id, coins); accountRepository.Refresh(account); Assert.AreEqual(original + coins, account.Coins); }
public void LoginTest() { IUserService accountSrv = new UserService(); UserAppService target = new UserAppService(accountSrv); string userName = "******"; string password = "******"; bool expected = true; bool actual; actual = target.Login(userName, password); Assert.AreEqual(expected, actual); }
public void ChangePasswordTest() { IUserService accountSrv = new UserService(); UserRepository accountRepository = new UserRepository(); UserAppService target = new UserAppService(accountSrv); Guid accountId = new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"); var account = accountRepository.Get(accountId); string password = "******"; target.ChangePassword(accountId, "123456", password); accountRepository.Refresh(account); Assert.AreEqual(account.Password, DataCryptography.EncryptString(password)); }
public GFMembershipProvider() { userService = new UserAppService(); }