public void IndexDisplayByDefaultTheFirstsProblems()
        {
            var problems = _session.List<Problem>(10).Get();

            var problemRepository = A.Fake<IProblemRepository>();
            var homeController = new HomeController(problemRepository);

            A.CallTo(() => problemRepository.All(0)).Returns(problems);
            A.CallTo(() => problemRepository.Count()).Returns(120);

            var result = homeController.Index() as ViewResult;
            var problemsResult = result.ViewData.Model as ProblemListModel;

            Assert.That(result, Is.Not.Null);
            Assert.That(problemsResult.NbProblemsTotal, Is.EqualTo(120));
            Assert.That(problemsResult.Problems.Count(), Is.EqualTo(10));
            A.CallTo(() => problemRepository.All(0)).MustHaveHappened();
        }
        public void IndexDisplayNoProblemWhenNoProblemInRepo()
        {
            var problemRepository = A.Fake<IProblemRepository>();
            var homeController = new HomeController(problemRepository);

            A.CallTo(() => problemRepository.All(0)).Returns(new List<Problem>());
            A.CallTo(() => problemRepository.Count()).Returns(0);

            var result = homeController.Index() as ViewResult;
            var problemsResult = result.ViewData.Model as ProblemListModel;

            Assert.That(result, Is.Not.Null);
            Assert.That(problemsResult.NbProblemsTotal, Is.EqualTo(0));
            Assert.That(problemsResult.Problems.Count(), Is.EqualTo(0));
            A.CallTo(() => problemRepository.All(0)).MustHaveHappened();
        }
 public void IndexShowErrorWhenPageNumberIsNegative()
 {
     var homeController = new HomeController(null);
     Assert.That(() => homeController.Index(-1), Throws.TypeOf<HttpException>());
 }