Beispiel #1
0
        public async Task GetOne_JournalNotFound_ReturnsBadRequest()
        {
            _mockService.Setup(s =>
                               s.GetById(It.IsAny <long>()))
            .ReturnsAsync(() => null);

            _controller = new JournalsController(_mockService.Object, _logger);

            var result = await _controller.GetOne(1L);

            result.Should().BeOfType <NotFoundResult>();
        }
Beispiel #2
0
        public async Task GetOne_JournalFound_ReturnsOk()
        {
            var journal = new Journal
            {
                Id     = 1L,
                Title  = "My Journal",
                UserId = "UserId"
            };

            _mockService.Setup(s =>
                               s.GetById(It.IsAny <long>()))
            .ReturnsAsync(new JournalDto(journal));

            _controller = new JournalsController(_mockService.Object, _logger);

            var result = await _controller.GetOne(1L);

            result.Should().BeOfType <OkObjectResult>();
        }