If you're willing to use an open-source framework, you could use Fluent Assertions and do this:


  Action act = () => subject.Foo2("Hello");
  
  act.ShouldThrow()
       .WithInnerException()
       .WithInnerMessage("whatever");


How to capture Exception in nSpec
I am using below code to get the user login gender information &amp; store in SESSION, I want to call below code after login, I already try this hook function bartik_user_login(&amp;$edit, $account) {}but its not working. Please help. Thanks

if (user_is_logged_in())
{    
global $user;
    $uid = user_load($user-&gt;uid);
    $profile_main = profile2_load_by_user($uid, 'main');
    $field_iam = field_get_items('profile2',$profile_main,'field_i_am_field');
    $_SESSION['i_am']=$field_iam[0][value];
    echo $_SESSION['i_am'];
}

