public async Task GetUserNotify_Success_Himself() { //Arrange------------------------------------------------------------------------------------------------------------------------------ // _mockRepo.Setup(x => x.NotificationRepository.GetManyAsync( //It.IsAny<Expression<Func<Notification, bool>>>(), //It.IsAny<Func<IQueryable<Notification>, IOrderedQueryable<Notification>>>(), //It.IsAny<string>())) //.ReturnsAsync(UnitTestsDataInput.notify_Success); var claims = new[] { new Claim(ClaimTypes.NameIdentifier, UnitTestsDataInput.userLogedInId), }; var identity = new ClaimsIdentity(claims); var claimsPrincipal = new ClaimsPrincipal(identity); var mockContext = new Mock <HttpContext>(); mockContext.SetupGet(x => x.User).Returns(claimsPrincipal); _controller.ControllerContext = new ControllerContext { HttpContext = mockContext.Object }; //Act---------------------------------------------------------------------------------------------------------------------------------- var result = await _controller.GetUserNotify(UnitTestsDataInput.userLogedInId); var okResult = result as OkObjectResult; //Assert------------------------------------------------------------------------------------------------------------------------------- Assert.NotNull(okResult); Assert.IsType <Notification>(okResult.Value); Assert.Equal(200, okResult.StatusCode); }