public void Initialize()
        {
            DbContextHelpers contextHelpers = new DbContextHelpers();
            search = new CategorySearch();

            db = contextHelpers.getDbContext();
            adminCon = new AdminCategoriesController(db.Object)
            {
                // sign in as admin
                ControllerContext = MockContext.AuthenticationContext("admin")
            };
        }
        /// <summary>
        /// Sets the session search parameters based on the current search values
        /// </summary>
        /// <param name="search">The WorkoutSearch object containing the values to set in the session</param>
        private void setSessionFromSearch(CategorySearch search)
        {
            if (Session != null)
            {
                if (!String.IsNullOrEmpty(search.name)) Session["NameSearchParam"] = search.name;
                else Session["NameSearchParam"] = "";

                if (!String.IsNullOrEmpty(search.description)) Session["DescriptionSearchParam"] = search.description;
                else Session["DescriptionSearchParam"] = "";

            }
        }
        /// <summary>
        /// Private helper method to perform a new search or maintain a previous search through 
        /// pagination and filter changes
        /// </summary>
        /// <param name="workouts">The base workout query result</param>
        /// <param name="sortBy">The passed sort string if it exists, else null</param>
        /// <param name="page">The passed page param if it exists, else null</param>
        /// <returns>The searched workouts</returns>
        private IQueryable<category> doSearch(IQueryable<category> categories, CategorySearch search, String filterString, string sortBy, int? page)
        {
            if (page != null || !String.IsNullOrEmpty(sortBy) || !String.IsNullOrEmpty(filterString))
            {
                search = setSearchFromSession(search);
            }
            else setSessionFromSearch(search);

            if (!String.IsNullOrEmpty(search.name)) categories = categories.Where(c => c.name.Contains(search.name));
            if (!String.IsNullOrEmpty(search.description)) categories = categories.Where(c => c.description.Contains(search.description));

            return categories;
        }
 /// <summary>
 /// Sets the WorkoutSearch object with the stored session search variables if they exist
 /// </summary>
 /// <param name="search">The WorkoutSearch object to set</param>
 /// <returns>The WorkoutSearch object set with the session search variables if the session exists, else the passed in WorkoutSearch object</returns>
 private CategorySearch setSearchFromSession(CategorySearch search)
 {
     if (Session != null)
     {
         search.name = Session["NameSearchParam"] as String;
         search.description = Session["DescriptionSearchParam"] as String;
     }
     return search;
 }
        // GET: AdminCategories
        public ActionResult Index(string filterString, string sortBy, int? page, CategorySearch categorySearch)
        {
            var categories = from c in db.categories select c;
            categories = this.doSearch(categories, categorySearch, filterString, sortBy, page);
            categories = this.doSort(categories, sortBy);

            int pageNumber = (page ?? 1);
            var view = View("Index", categories.ToPagedList(pageNumber, pageSize));
            return view;
        }