示例#1
0
        public void ShouldReturnView_WithCommentsForGame()
        {
            var comments = new List <CommentDto>
            {
                new CommentDto(
                    id: 1,
                    name: "name",
                    body: "body",
                    gameId: 1,
                    parentCommentId: null,
                    repliedTo: string.Empty,
                    quote: string.Empty,
                    isQuote: false)
            };

            _commentServiceMock
            .Setup(m => m.GetAllCommentsByGameKey(It.IsAny <string>()))
            .Returns(comments);

            _gameServiceMock
            .Setup(m => m.GetGameByKey(It.IsAny <string>()))
            .Returns(new GameDto {
                LanguagesNames = new Dictionary <string, string> {
                    { "ru", "name" }
                }
            });

            var viewResult = _commentController.GetAllCommentsForGame(It.IsAny <string>());
            var model      = viewResult.Model as CommentsViewModel;

            Assert.NotNull(model);
            Assert.NotNull(model.Comments);
            Assert.AreEqual(model.Comments.Count, comments.Count);
        }