Пример #1
0
        public void Add()
        {
            try
            {
                _unitOfWork = new UnitOfWork();
                IUserRepository userRepository = new UserUnitOfWorkRepository(_unitOfWork);
                if (userRepository.GetByKey(_id) == null)
                {
                    userRepository.Add(new User() { Id = _id, Duty = "管理员", Name = "hy", Email = "bbs", RoleId = "SuperManager",Password="hy" });
                }

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false);
            }
        }
Пример #2
0
        public void Get()
        {
            try
            {
                _unitOfWork = new UnitOfWork();
                IUserRepository userRepository = new UserUnitOfWorkRepository(_unitOfWork);
                User user = userRepository.GetByKey(_id);

                Assert.AreEqual<System.Guid>(user.Id, _id);

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false);
            }
        }
Пример #3
0
        public void Del()
        {
            try
            {
                _unitOfWork = new UnitOfWork();
                IUserRepository userRepository = new UserUnitOfWorkRepository(_unitOfWork);
                userRepository.Del(new User() { Id = _id });

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false);
            }
        }
Пример #4
0
        public void Save()
        {
            try
            {
                _unitOfWork = new UnitOfWork();
                IUserRepository userRepository = new UserUnitOfWorkRepository(_unitOfWork);

                User user = userRepository.GetByKey(_id);
                user.Name = "polan";
                userRepository.Save(user);

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false);
            }
        }
Пример #5
0
        public void GetAll()
        {
            try
            {
                _unitOfWork = new UnitOfWork();
                IUserRepository userRepository = new UserUnitOfWorkRepository(_unitOfWork);
                List<User> list = userRepository.GetAll().ToList();
                Assert.IsTrue(list != null && list.Count > 0);

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false);
            }
        }