Ejemplo n.º 1
0
        private IActionResult TryGetMatchComments(int matchId)
        {
            ICollection <CommentaryDto>   matchComments = encounterService.GetEncounterCommentaries(matchId);
            ICollection <CommentModelOut> output        = matchComments.Select(c => BuildCommentModelOut(c)).ToList();

            return(Ok(output));
        }
        public void GetCommentsOfUnexistentEncounterTest()
        {
            Mock <IEncounterRepository> fakeRepo = new Mock <IEncounterRepository>();

            fakeRepo.Setup(r => r.Get(It.IsAny <int>())).Throws(new EncounterNotFoundException());
            serviceToTest = new EncounterService(fakeRepo.Object, teamsRepo, sportsRepo, usersRepo, auth.Object);
            serviceToTest.GetEncounterCommentaries(8);
        }
        public void GetMatchCommentsTest()
        {
            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();
            serviceToTest.CommentOnEncounter(added1.Id, commentarist.UserName, "a Comment");
            serviceToTest.CommentOnEncounter(added1.Id, commentarist.UserName, "another Comment");
            serviceToTest.CommentOnEncounter(added2.Id, commentarist.UserName, "a Comment");
            ICollection <CommentaryDto> comments = serviceToTest.GetEncounterCommentaries(added1.Id);

            Assert.AreEqual(comments.Count, 2);
        }