public void SetupTest()
        {
            _db = DatabaseHelper.CreateNewDatabase();
            user = new user
            {
                username = "******",
                first_name = "FirstName",
                middle_name = "MiddleName",
                last_name = "LastName",
                is_player = true,
                created_date = DateTime.Now,
                status = (int)JPPConstants.UserStatus.Active,
                first_login = true,
                email = "*****@*****.**",
                last_login_date = DateTime.Now,
                display_name = "DisplayName",
                privacy_settings = (int)JPPConstants.PrivacySettings.JustPressPlayOnly,
                has_agreed_to_tos = false,
                creator_id = null
            };

            _db.user.Add(user);

            DatabaseHelper.TrySaveChanges(ref _db);
        }
        /// <summary>
        /// Determines if the logged in user has access to the earning
        /// </summary>
        /// <param name="earningID">The ID of the earning</param>
        /// <param name="earningIsAchievement">Is the earning an achievement?  If not, it's a quest</param>
        /// <param name="work">The DB access</param>
        /// <returns>True if the user can access, false otherwise</returns>
        private bool UserCanAccessEarning(int earningID, bool earningIsAchievement, UnitOfWork work, out user earningUser, out object earningTemplate)
        {
            // Set up out param
            earningUser = null;
            earningTemplate = null;

            // Assume invalid, then check
            bool valid = false;
            if (earningIsAchievement)
            {
                // Base query for achievements
                var q = from e in work.EntityContext.achievement_instance
                        where e.id == earningID
                        select e;

                // Can the user "see" this earning?
                var mine = from e in q
                           where e.user_id == WebSecurity.CurrentUserId
                           select e;

                var publicUsers = from e in q
                                  where e.user.privacy_settings != (int)JPPConstants.PrivacySettings.FriendsOnly
                                  select e;

                var friendOnlyFriends = from e in q
                                        join f in work.EntityContext.friend
                                        on e.user_id equals f.source_id
                                        where e.user.privacy_settings == (int)JPPConstants.PrivacySettings.FriendsOnly &&
                                            f.destination_id == WebSecurity.CurrentUserId
                                        select e;

                // Concat the queries and see if we have anything
                achievement_instance instance = mine.Concat(publicUsers).Concat(friendOnlyFriends).FirstOrDefault();
                if (instance != null)
                {
                    valid = true;
                    earningUser = instance.user;
                    earningTemplate = instance.achievement_template;
                }
            }
            else
            {
                // Base query for quests
                var q = from e in work.EntityContext.quest_instance
                        where e.id == earningID
                        select e;

                // Check different scenarios
                var mine = from e in q
                           where e.user_id == WebSecurity.CurrentUserId
                           select e;

                var publicUsers = from e in q
                                  where e.user.privacy_settings != (int)JPPConstants.PrivacySettings.FriendsOnly
                                  select e;

                var friendOnlyFriends = from e in q
                                        join f in work.EntityContext.friend
                                        on e.user_id equals f.source_id
                                        where e.user.privacy_settings == (int)JPPConstants.PrivacySettings.FriendsOnly &&
                                            f.destination_id == WebSecurity.CurrentUserId
                                        select e;

                // Concat the queries and see if we have anything
                quest_instance instance = mine.Concat(publicUsers).Concat(friendOnlyFriends).FirstOrDefault();
                if (instance != null)
                {
                    valid = true;
                    earningUser = instance.user;
                    earningTemplate = instance.quest_template;
                }
            }

            return valid;
        }