Esempio n. 1
0
        public void ImpersonatedAccountCleanup()
        {
            if(ImpersonatedAccount != null)
            {
                ImpersonatedAccount.Dispose();
            }

            ImpersonatedAccount = null;

            ServiceLocator.CachingManager.Clear();
        }
Esempio n. 2
0
        /// <summary>
        /// This will impersonate the agent with the email address defined inside the UserTestData file.
        /// 
        /// This user must have an agent and user account already established for this impersonation to work
        /// </summary>
        private User ImpersonateAgent(out int? agentId, out int? userId)
        {
            var agentRepo = RepositoryFactory.Get<User>();

            var userName = TestConfigSettings.Instance().UnitTestsImpersonatedAgentUsername;

            if(userName == null)
                throw new ApplicationException("Missing config value - UnitTestsImpersonatedAgentUsername");

            var agent =
                agentRepo.Get(a => a.Username == userName).SingleOrDefault();

            if (agent == null)
                Assert.Inconclusive("There is no valid agent with email " + userName + " to impersonate in the DB");

            ImpersonatedAccount = new ImpersonatedAccount(TestConfigSettings.Instance().UnitTestsImpersonatedAgentUsername);

            agentId = agent.UserId;
            userId = agent.UserId;
            
            return agent;
        }