コード例 #1
0
        public void AddComment_ExistingGameIdAndCommentDto_ReturnsTrue()
        {
            int id         = 1;
            var commentDto = new CommentDto();
            var game       = new Game()
            {
                Id = id, Comments = new List <Comment>()
            };

            _unitOfWorMock.Setup(uof => uof.GameGenericRepository.Get(id)).Returns(game);

            var result           = _sut.Get(id);
            var addCommentResult = _sut.AddComment(id, commentDto);

            Assert.True(addCommentResult.Succeed);
        }
コード例 #2
0
        public ActionResult NewComment(string key, string commentJson, int?id)
        {
            var game = _gameService.GetByKey(key).First();

            var commentDto = JsonConvert.DeserializeObject <CommentDto>(commentJson);

            if (id != null)
            {
                commentDto.ParentCommentId = id;
            }

            _gameService.AddComment(game.Id, commentDto);

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }