Пример #1
0
        public void SetUp()
        {
            _users = new List<User>()
                         {
                             new User { Email = "*****@*****.**", FullName = "aaa ddd", FirstName = "aaa", LastName = "ddd", Live = LiveStatuses.Active, ApproveState = ApproveStates.Approved, Role = Roles.Simple },
                             new User { Email = "*****@*****.**", FullName = "aaa bbb", FirstName = "aaa", LastName = "bbb", Live = LiveStatuses.Active, ApproveState = ApproveStates.Approved, Role = Roles.Admin }
                         };

            var mock = new Mock<ControllerContext>();
            mock.Setup(p => p.HttpContext.Session).Returns(new Mock<HttpSessionStateBase>().Object);

            DiMvc.Register();
            Ioc.RegisterType<IUserRepository, UserRepository>();

            _repoUnit = new RepoUnit();

            var lastRecord = _repoUnit.User.Load();
            _lastDbRecordId = !lastRecord.Any() ? 0 : lastRecord.Max(user => user.Id);

            _users.ForEach(user => _repoUnit.User.Save(user));

            var service = new UserService(_repoUnit, null)
                              {
                                  //PageSize = lastRecord.Count() + _users.Count //Prevent paging
                              };

            _usersController = new UsersController(service);

            _usersController.ControllerContext = mock.Object;
        }
Пример #2
0
        public void SetUp()
        {
            DiMvc.Register();
            Ioc.RegisterType<IConfig, FakeConfig>();

            _config = Ioc.Resolve<IConfig>() as FakeConfig;

            _users = new List<User>()
                         {
                             new User { Email = "*****@*****.**", FullName = "aaa ddd", FirstName = "aaa", LastName = "ddd"},
                             new User { Email = "*****@*****.**", FullName = "aaa bbb", FirstName = "aaa", LastName = "bbb"}
                         };

            _repoUnit = new RepoUnit();
            _users.ForEach(_repoUnit.User.Save);

            var userService = new UserService(_repoUnit, null);
            Ioc.RegisterInstance<UserService>(userService);

            var mock = new Mock<ControllerContext>();
            mock.Setup(p => p.HttpContext.Session).Returns(new Mock<HttpSessionStateBase>().Object);

            _usersController = new UsersController(userService) { ControllerContext = mock.Object };

            _config.PageSize = 1;
        }
Пример #3
0
        public void SetUpFixture()
        {
            FakeDi.Register();

            _repository = new FakeUserRepository();
            Ioc.RegisterInstance<IUserRepository>(_repository);

            //Setup UserController dependencies
            _userController = Ioc.Resolve<UsersController>();

            var mock = new Mock<ControllerContext>();
            mock.Setup(p => p.HttpContext.Session).Returns(new Mock<HttpSessionStateBase>().Object);
            _userController.ControllerContext = mock.Object;
        }
Пример #4
0
        public void SetUp()
        {
            Database.SetInitializer(new FastDbInitializer(1000));

            try
            {
                var _context = new CalendarContext();
                _context.Database.Initialize(true);
            }
            catch { /* Do nothing */ }

            DiMvc.Register();
            Ioc.RegisterType<IUserRepository, UserRepository>();

            var mock = new Mock<ControllerContext>();
            mock.Setup(p => p.HttpContext.Session).Returns(new Mock<HttpSessionStateBase>().Object);

            _usersController = Ioc.Resolve<UsersController>();
            _usersController.ControllerContext = mock.Object;
        }