public async Task GetAll_JournalsNotFound_ReturnsBadRequest() { _mockService.Setup(s => s.GetAll(It.IsAny <string>(), 5)) .ReturnsAsync(() => null); _controller = new JournalsController(_mockService.Object, _logger); var result = await _controller.GetAll("UserId", 5); result.Should().BeOfType <NotFoundResult>(); }
public async Task GetAll_UserFound_ReturnsOkWithList() { const string userId = "UserId"; var journals = new List <JournalDto>(); for (var i = 0; i < 5; i++) { journals.Add(new JournalDto { Title = $"Journal {i + 1}", UserId = userId }); } _mockService.Setup(s => s.GetAll(It.IsAny <string>(), 5)) .ReturnsAsync(journals); _controller = new JournalsController(_mockService.Object, _logger); var result = await _controller.GetAll(userId, page : 5); result.Should().BeOfType <OkObjectResult>(); }