Esempio n. 1
0
        private IActionResult TryGetAllComments()
        {
            ICollection <CommentaryDto>   allComments = encounterService.GetAllCommentaries();
            ICollection <CommentModelOut> output      = allComments.Select(c => BuildCommentModelOut(c)).ToList();

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

            fakeRepo.Setup(r => r.GetComments()).Throws(new DataInaccessibleException());
            serviceToTest = new EncounterService(fakeRepo.Object, teamsRepo, sportsRepo, usersRepo, auth.Object);
            serviceToTest.GetAllCommentaries();
        }
        public void GetCommentsTest()
        {
            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.GetAllCommentaries();

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