Пример #1
0
 public void Cleanup()
 {
     _repository = null;
     _service = null;
     _users = null;
     _unitOfWork = null;
     MockRepository = null;
 }
Пример #2
0
        public void Initialize()
        {
            MockRepository = new Mock<IRepository<UserDetail>>();
            _user = new UserDetail { Name = "Ashutosh", Password = "******", UserRole = UserRole.Admin, DateOfCreation = DateTime.UtcNow };
            _users = new List<UserDetail> { _user };
            _users = _users.Concat(new List<UserDetail>
                        {
                        new UserDetail { Name = "Monny", Password = "******", UserRole = UserRole.DeparmentHead, DateOfCreation = DateTime.UtcNow },
                        new UserDetail { Name = "Jhonny", Password = "******", UserRole = UserRole.Principal, DateOfCreation = DateTime.UtcNow },
                        new UserDetail { Name = "Pony", Password = "******", UserRole = UserRole.Student, DateOfCreation = DateTime.UtcNow },
                        new UserDetail { Name = "Tony", Password = "******", UserRole = UserRole.Teacher, DateOfCreation = DateTime.UtcNow },
                        new UserDetail { Name = "Sunny", Password = "******", UserRole = UserRole.Admin, DateOfCreation = DateTime.UtcNow }
                        });

            MockRepository.Setup(_ => _.Query()).Returns(_users.AsQueryable());
            MockRepository.Setup(_ => _.Add(_user)).Returns(_user);
            MockRepository.Setup(_ => _.Remove(_user)).Returns(_user);
            _repository = MockRepository.Object;
            _service = new UserService(_repository, _unitOfWork);
        }