public void CancelPayTest(long cardOrCode) { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "name"), new Claim(ClaimTypes.Role, "role") }, "mock")); cart.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; IActionResult cancelPay = cart.CancelPay(cardOrCode); Assert.IsType <RedirectToActionResult>(cancelPay); }