title: .net core Url.Action mock, how to?
body: <p>How to mock Url.Action during testing controller action?</p>
  
  <p>I'm trying to unit test my asp.net core controller action.
  Logic of action has Url.Action and I need to mock it to complete test but I can't find right solution.</p>
  
  <p>Thank you for your help!</p>
  
  <p><strong>UPDATE</strong>
  this is my method in controller that I need to test.</p>
  
  <pre><code>    public async Task&lt;IActionResult&gt; Index(EmailConfirmationViewModel model)
      {
          if (ModelState.IsValid)
          {
              var user = await _userManager.FindByNameAsync(model.Email);
  
              if (user == null) return RedirectToAction("UserNotFound");
              if (await _userManager.IsEmailConfirmedAsync(user)) return RedirectToAction("IsAlreadyConfirmed");
  
              var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
              var callbackUrl = Url.Action("Confirm", "EmailConfirmation", new { userId = user.Id, token }, HttpContext.Request.Scheme);
  
              await _emailService.SendEmailConfirmationTokenAsync(user, callbackUrl);
  
              return RedirectToAction("EmailSent");
          }
  
          return View(model);
      }
  </code></pre>
  
  <p>I have problem with mocking this part:</p>
  
  <pre><code>var callbackUrl = Url.Action("Confirm", "EmailConfirmation", new { userId = user.Id, token }, HttpContext.Request.Scheme);
  </code></pre>