public void GetUser()
        {
            string username = "******";
            var roles = new[] { "Employee" };
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(username), roles);

            var repository = new UserRepository(LDAPStore, exceptionMgr, container);
            var user = repository.GetUser(username);

            Assert.IsNotNull(user);
            Assert.AreEqual(username, user.UserName);
            Assert.AreEqual(1, user.Roles.Count);
            Assert.AreEqual("Employee", user.Roles.First());
            Assert.AreEqual("John Doe", user.FullName);
            Assert.AreEqual("ADATUM\\mary", user.Manager);
            Assert.AreEqual("31023", user.CostCenter);
        }
        public void UpdatePreferredReimbursementMethod()
        {
            string username = "******";
            var roles = new[] { "UpdatePreferredReimbursementMethod_Role" };
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(username), roles);
            var repository = new UserRepository(LDAPStore, exceptionMgr, container);

            var actual = repository.GetUser(username);
            actual.PreferredReimbursementMethod = ReimbursementMethod.Cash;

            repository.UpdateUserPreferredReimbursementMethod(actual);

            var updated = repository.GetUser(username);

            Assert.IsNotNull(updated);
            Assert.AreEqual(ReimbursementMethod.Cash, updated.PreferredReimbursementMethod);
        }
        public void GetWrongUserReplacesException()
        {
            string username = "******";
            var roles = new[] { "Employee" };
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(username), roles);

            var repository = new UserRepository(LDAPStore, exceptionMgr, container);

            //assert that the friendly excetpion is thrown to the UI
            var ex = ExceptionAssertHelper.Throws<NotifyException>(
              () => repository.GetUser(username));

            Assert.IsNotNull(ex, "Exception not thrown");
            StringAssert.Contains(ex.Message, Resources.FriendlyMessage);

            //assert that the inner execption is logged to the database

            var errors = DatabaseHelper.GetExceptionsFromDB(LoggingDatabaseConnectionString);
            var error = errors.FirstOrDefault();
            Assert.IsNotNull(error, "Inner exception not logged to the db");
            StringAssert.Contains(error.FormattedMessage, Resources.UserNotRegisteredMessage);
            StringAssert.Contains(error.Title, Resources.NotifyExceptionTitle);

        }
        public void UpdatePreferredReimbursementMethodUsingBootstrapper()
        {
            string username = "******";
            var roles = new[] { "Employee" };
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(username), roles);
            var repository = container.Resolve<IUserRepository>();

            var actual = repository.GetUser(username);
            actual.PreferredReimbursementMethod = ReimbursementMethod.Cash;

            repository.UpdateUserPreferredReimbursementMethod(actual);

            var updated = repository.GetUser(username);

            Assert.IsNotNull(updated);
            Assert.AreEqual(ReimbursementMethod.Cash, updated.PreferredReimbursementMethod);
        }