public void CommentOnMatchByIdsTest()
        {
            UserId identity = new UserId()
            {
                Name = "name", Surname = "surname", UserName = "******", Password = "******", Email = "*****@*****.**"
            };
            User commentarist = new User(identity, true);

            teamsRepo.Add(teamA);
            teamsRepo.Add(teamB);
            usersRepo.Add(commentarist);
            Encounter added = matchesRepo.Add(matchAvsB);

            SetUpRepository();
            serviceToTest.CommentOnEncounter(added.Id, commentarist.UserName, "a Comment");
        }
Exemplo n.º 2
0
        private IActionResult TryAddComment(int matchId, CommentModelIn input)
        {
            string          username = HttpContext.User.Claims.First(c => c.Type.Equals(AuthenticationConstants.USERNAME_CLAIM)).Value;
            CommentaryDto   created  = encounterService.CommentOnEncounter(matchId, username, input.Text);
            CommentModelOut output   = new CommentModelOut
            {
                Id            = created.commentId,
                MakerUsername = username,
                Text          = input.Text
            };

            return(CreatedAtRoute("GetCommentById", new { id = output.Id }, output));
        }
        public void CommentNoMatchNoDataAccessTest()
        {
            Mock <IEncounterRepository> fakeRepo = new Mock <IEncounterRepository>();

            fakeRepo.Setup(r => r.CommentOnEncounter(It.IsAny <int>(), It.IsAny <Commentary>())).Throws(new DataInaccessibleException());
            serviceToTest = new EncounterService(fakeRepo.Object, teamsRepo, sportsRepo, usersRepo, auth.Object);
            UserId identity = new UserId()
            {
                Name = "name", Surname = "surname", UserName = "******", Password = "******", Email = "*****@*****.**"
            };
            User commentarist = new User(identity, true);

            teamsRepo.Add(teamA);
            teamsRepo.Add(teamB);
            usersRepo.Add(commentarist);
            Encounter added = matchesRepo.Add(matchAvsB);

            serviceToTest.CommentOnEncounter(added.Id, commentarist.UserName, "a Comment");
        }