public void POST_Close() { //Arrange var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, "123"), }); var principal = new ClaimsPrincipal(identity); var context = new Mock <HttpContextBase>(); context.SetupGet(x => x.User).Returns(principal); var routeData = new RouteData(); _controller.ControllerContext = new ControllerContext(context.Object, routeData, _controller); _patientService.Setup(x => x.ClosePatientTracking(It.IsAny <int>())); _patientService.Setup(x => x.Log(It.IsAny <OperationType>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())); //Act var result = (RedirectToRouteResult)_controller.Close(1); //Assert Assert.That(result.RouteValues["action"], Is.EqualTo("View")); }