예제 #1
0
        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);
            }
        }
예제 #2
0
        public static AptMgmtPortalAPI.DTO.UserDTO NewUserDtoWithCredential(AptMgmtDbContext context)
        {
            var userDto = new AptMgmtPortalAPI.DTO.UserDTO
            {
                FirstName = "original first name",
                LoginName = "testUser",
                Password  = "******"
            };

            return(userDto);
        }
예제 #3
0
        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);
            }
        }