public async Task GetExam_ValidExamIdPassed_ReturnsOkObjectResult() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "1"), })); var mapperMock = new Mock <IMapper>(); var repositoryMock = new Mock <IRepositoryWrapper>(); repositoryMock.Setup(r => r.ExamRepository.GetExamAsync(It.IsAny <int>())).ReturnsAsync(new Exam()); var controllerMock = new ExamsController(repositoryMock.Object, mapperMock.Object); controllerMock.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user } }; var result = await controllerMock.GetExamAsync(1); Assert.IsType <OkObjectResult>(result); }