title: C sharp unit test
body: <p><em>Could you please help me with writing UnitTest for this method? I tried a couple of ways but I could not solve it.</em></p>
  
  <pre><code>public ActionResult ChangePass()
  {
      if (Request.IsAuthenticated)
      {
          return View();
      }
      else
      {
          return RedirectToAction("Index", "Index", new { area = "" });
      }
  }
  </code></pre>
  
  <p><em>Here is what I am trying to do.</em></p>
  
  <pre><code>[TestMethod]
      public void ChangePass()
      {
  
          var identity = new GenericIdentity("admin@gmail.com");
          var controller = new ProfilePageController();
          var controllerContext = new Mock&lt;ControllerContext&gt;();
          var principal = new Mock&lt;IPrincipal&gt;();
         principal.Setup(p =&gt; p.IsInRole("user")).Returns(true);
          principal.SetupGet(x =&gt; x.Identity.Name).Returns("admin@gmail.com");
          controllerContext.SetupGet(x =&gt; x.HttpContext.User).Returns(principal.Object);
          controller.ControllerContext = controllerContext.Object;
          NUnit.Framework.Assert.AreEqual(controller.ChangePass(), identity.Name);
          }
  </code></pre>