public async void EditsUserInfo() { var options = TestUtil.GetMemDbOptions("EditsUserInfo"); var mock = new Mock <ILogger <UserRepository> >(); AptMgmtPortalAPI.Entity.User user; using (var db = new AptMgmtDbContext(options)) { var repo = (IUser) new UserRepository(mock.Object, db); var userInfoandTenant = TestUtil.UserInfoAndTenantForUserRepo(db); user = await repo.NewUser(userInfo : userInfoandTenant.Item1); } using (var db = new AptMgmtDbContext(options)) { var repo = (IUser) new UserRepository(mock.Object, db); var newName = "new first name"; var userInfo = new AptMgmtPortalAPI.DTO.UserDTO { UserId = user.UserId, FirstName = newName, LoginName = user.LoginName, Password = user.Password }; var newInfo = await repo.UpdateUserInfo(userInfo); Assert.Equal(newName, newInfo.FirstName); } }
public static AptMgmtPortalAPI.DTO.UserDTO NewUserDtoWithCredential(AptMgmtDbContext context) { var userDto = new AptMgmtPortalAPI.DTO.UserDTO { FirstName = "original first name", LoginName = "testUser", Password = "******" }; return(userDto); }
public async void EditsUserInfoWithId() { var options = TestUtil.GetMemDbOptions("EditsUserInfo"); var mock = new Mock <ILogger <UserRepository> >(); AptMgmtPortalAPI.Entity.User user; using (var db = new AptMgmtDbContext(options)) { var repo = (IUser) new UserRepository(mock.Object, db); var userInfo = TestUtil.NewUserDtoWithCredential(db); var tenant = new Tenant { Email = "testUser", UserId = userInfo.UserId, FirstName = "original first name", }; db.Add(tenant); db.SaveChanges(); user = await repo.NewUser(userInfo); } using (var db = new AptMgmtDbContext(options)) { var repo = (IUser) new UserRepository(mock.Object, db); var newName = "new first name"; var userInfo = new AptMgmtPortalAPI.DTO.UserDTO(); userInfo.FirstName = newName; userInfo.LoginName = user.LoginName; userInfo.Password = user.Password; var newInfo = await repo.UpdateUserInfo(user.UserId, userInfo); Assert.Equal(newName, newInfo.FirstName); } }