public object Get(GetTweetById request) { var tweet = _tweetRepo.GetById(request.Id); if (tweet == null) { ThrowNotFound(request.Id); } return(tweet); }
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() })); }
public ActionResult <TweetDTO> GetById(int tweetId) { var tweet = _tweetRepository.GetById(tweetId); if (tweet == null) { return(NotFound()); } return(Ok(new TweetDTO(tweet))); }