Example #1
0
        public object Get(GetTweetById request)
        {
            var tweet = _tweetRepo.GetById(request.Id);

            if (tweet == null)
            {
                ThrowNotFound(request.Id);
            }

            return(tweet);
        }
Example #2
0
        public void GetTweetById_throws_exception_when_the_tweet_is_not_found_test()
        {
            // Arrange
            _fakeTweetRepository.GetById(Arg.Any <Guid>()).Returns(x => null);
            var service = appHost.Container.Resolve <TweetService>();

            // Act & Assert
            Assert.Throws <HttpError>(() => service.Get(new GetTweetById {
                Id = Guid.NewGuid()
            }));
        }
Example #3
0
        public ActionResult <TweetDTO> GetById(int tweetId)
        {
            var tweet = _tweetRepository.GetById(tweetId);

            if (tweet == null)
            {
                return(NotFound());
            }

            return(Ok(new TweetDTO(tweet)));
        }