Exemplo n.º 1
0
        public void ReturnViewWhitModelWhenDiscussionIdIsNotNull()
        {
            var mockedDiscussionsService = new Mock <IDiscussionsService>();
            var mockedUsersService       = new Mock <IUsersService>();
            var mockedBooksService       = new Mock <IBooksService>();
            var mockedDiscussionUserData = new Mock <IDiscussionUsersData>();
            var mockedMapper             = new Mock <IMapper>();

            mockedDiscussionsService.Setup(x => x.GetById(1)).Returns(new Discussion());

            mockedMapper.Setup(m => m.Map <DetailDiscussionViewModel>(It.IsAny <Discussion>())).Returns(new DetailDiscussionViewModel());
            var discussionsController = new DiscussionsController(mockedDiscussionsService.Object, mockedUsersService.Object, mockedBooksService.Object, mockedDiscussionUserData.Object, mockedMapper.Object);

            discussionsController.GetById(1);

            discussionsController.WithCallTo(x => x.GetById(1)).ShouldRenderView("GetById").WithModel <DetailDiscussionViewModel>();
        }
Exemplo n.º 2
0
        public void CallDiscussionServiceGetByIdWhenDiscussionStatusIsNotNull()
        {
            var mockedDiscussionsService = new Mock <IDiscussionsService>();
            var mockedUsersService       = new Mock <IUsersService>();
            var mockedBooksService       = new Mock <IBooksService>();
            var mockedDiscussionUserData = new Mock <IDiscussionUsersData>();
            var mockedMapper             = new Mock <IMapper>();
            var mockedDiscussion         = new Mock <Discussion>();
            var mockedComment            = new Mock <Comment>();

            mockedDiscussionsService.Setup(x => x.GetById(1)).Returns(mockedDiscussion.Object);
            mockedMapper.Setup(m => m.Map <DetailDiscussionViewModel>(mockedDiscussion));
            mockedDiscussion.SetupGet(m => m.Comments).Returns(new List <Comment>()
            {
                mockedComment.Object
            });
            var discussionsController = new DiscussionsController(mockedDiscussionsService.Object, mockedUsersService.Object, mockedBooksService.Object, mockedDiscussionUserData.Object, mockedMapper.Object);

            discussionsController.GetById(1);

            mockedDiscussionsService.Verify(x => x.GetById(1), Times.Once());
        }