public async Task GetAllFinishLoan_Test() { var searchServiceMock = new Mock <ISearchService>().Object; var loanServiceMock = new Mock <ILoanService>().Object; var encodeDecodeServiceMock = new Mock <IEncodeDecodeService>().Object; var defaultContext = new DefaultHttpContext() { User = new ClaimsPrincipal() }; var controller = new LoanController(loanServiceMock, searchServiceMock, encodeDecodeServiceMock) { ControllerContext = new ControllerContext() { HttpContext = defaultContext } }; var result = await controller.GetAllFinishLoan(); Assert.IsInstanceOfType(result, typeof(ViewResult)); }