public void FetchComments_SetIDParamToOneIfNoneGiven()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            var fakeEmailService = new Mock<IEmailer>();
            var fakeViewMapper = new Mock<IViewMapper>();
            var request = new Mock<HttpRequestBase>();
            var context = new Mock<HttpContextBase>();

            context.Setup(x => x.Request).Returns(request.Object);

            var sut = new HomeController(fakePostRepository.Object, fakeEmailService.Object, fakeViewMapper.Object);

            sut.ControllerContext = new ControllerContext(context.Object,
                                   new RouteData(), sut);

            var viewResult = sut.FetchComments() as ViewResult;

            var model = viewResult.Model as List<Comment>;

            Assert.AreEqual(1, model[0].PostId);
        }
        public void FetchComments_ReturnTheCorrectModelType_IfNormalRequest()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            fakePostRepository.Setup(x => x.GetModeratedPostComments(1))
                              .Returns(It.IsAny<List<Comment>>());
            var fakeEmailService = new Mock<IEmailer>();
            var fakeViewMapper = new Mock<IViewMapper>();
            var request = new Mock<HttpRequestBase>();
            var context = new Mock<HttpContextBase>();

            context.Setup(x => x.Request).Returns(request.Object);

            var sut = new HomeController(fakePostRepository.Object, fakeEmailService.Object, fakeViewMapper.Object);

            sut.ControllerContext = new ControllerContext(context.Object,
                                   new RouteData(), sut);

            var viewResult = sut.FetchComments() as ViewResult;

            Assert.IsInstanceOf(typeof (List<Comment>), viewResult.Model);
        }
        public void FetchComments_ReturnTheCorrectView_IfNormalRequest()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            var fakeEmailService = new Mock<IEmailer>();
            var fakeViewMapper = new Mock<IViewMapper>();
            var request = new Mock<HttpRequestBase>();
            var context = new Mock<HttpContextBase>();

            context.Setup(x => x.Request).Returns(request.Object);

            var sut = new HomeController(fakePostRepository.Object, fakeEmailService.Object, fakeViewMapper.Object);

            sut.ControllerContext = new ControllerContext(context.Object,
                                   new RouteData(), sut);

            var viewResult = sut.FetchComments() as ViewResult;
            const string expected = "NonAjaxView";
            string actual = viewResult.ViewName;

            Assert.AreEqual(expected, actual);
        }
        public void FetchComments_CallMethod_GetModeratedPostComments()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            var fakeEmailService = new Mock<IEmailer>();
            var fakeViewMapper = new Mock<IViewMapper>();
            var request = new Mock<HttpRequestBase>();
            var context = new Mock<HttpContextBase>();

            context.Setup(x => x.Request).Returns(request.Object);

            var sut = new HomeController(fakePostRepository.Object, fakeEmailService.Object, fakeViewMapper.Object);

            sut.ControllerContext = new ControllerContext(context.Object,
                                   new RouteData(), sut);

            sut.FetchComments();

            fakePostRepository.Verify(x => x.GetModeratedPostComments(1), Times.Once());
        }