public void GetCommentNoDataAccess() { Mock <IEncounterRepository> fakeRepo = new Mock <IEncounterRepository>(); fakeRepo.Setup(r => r.GetComment(It.IsAny <int>())).Throws(new DataInaccessibleException()); serviceToTest = new EncounterService(fakeRepo.Object, teamsRepo, sportsRepo, usersRepo, auth.Object); serviceToTest.GetComment(3); }
public void GetCommentTest() { UserId identity = new UserId() { Name = "name", Surname = "surname", UserName = "******", Password = "******", Email = "*****@*****.**" }; User commentarist = new User(identity, true); usersRepo.Add(commentarist); teamsRepo.Add(teamA); teamsRepo.Add(teamB); teamsRepo.Add(teamC); Encounter added1 = matchesRepo.Add(matchAvsB); Encounter added2 = matchesRepo.Add(matchAvsC); SetUpRepository(); CommentaryDto comment = serviceToTest.CommentOnEncounter(added1.Id, commentarist.UserName, "a Comment"); CommentaryDto retrieved = serviceToTest.GetComment(comment.commentId); Assert.AreEqual(comment.text, retrieved.text); }
private IActionResult TryGetComment(int id) { CommentaryDto comment = encounterService.GetComment(id); CommentModelOut output = new CommentModelOut { Id = comment.commentId, MakerUsername = comment.makerUsername, Text = comment.text }; return(Ok(output)); }