public void GivenGuid_WhenIConfirmEmail_ThenViewHasViewModel()
        {
            ConfirmEmailModel expected = new ConfirmEmailModel();
            Guid expectedIdentifier = Guid.NewGuid();
            MockAccountManager.Expect(m => m.GenerateConfirmEmailViewModel(expectedIdentifier)).Return(expected);

            ViewResult actual = Target.ConfirmEmail(expectedIdentifier);

            actual.AssertGetViewModel(expected);
        }
 public ConfirmEmailModel GenerateConfirmEmailViewModel(Guid confirmationIdentifier)
 {
     ConfirmEmailModel viewModel;
     User user = UserRepository.Items.SingleOrDefault(u => u.ConfirmationGuid == confirmationIdentifier);
     if (user == null || UserRepository.Items.Any(u => u.Id != user.Id && u.EmailAddress == user.PendingEmail))
     {
         return new ConfirmEmailModel { Success = false };
     }
     viewModel = new ConfirmEmailModel { Success = true, UserDisplayName = user.DisplayName, UserEmailAddress = user.PendingEmail };
     EmailConfirmationManager.Process(user);
     UserRepository.Update(user);
     RepositoryContainer.Save();
     return viewModel;
 }