コード例 #1
0
        public void ReturnsCorrectlyWhenNonWorkerViewsPage()
        {
            Mock <IListWorkerJobsService> mockedService =
                new Mock <IListWorkerJobsService>();

            mockedService.Setup(a => a.IsWorker()).Returns(false);
            ListWorkerJobsController listWorkerJobsController =
                new ListWorkerJobsController(mockedService.Object);
            var result = listWorkerJobsController.Index();

            Assert.That(result is RedirectResult);
        }
コード例 #2
0
        public void ReturnsCorrectlyWhenWorkerHasNoActiveJobs()
        {
            Mock <IListWorkerJobsService> mockedService =
                new Mock <IListWorkerJobsService>();

            mockedService.Setup(a => a.IsWorker()).Returns(true);
            mockedService.Setup(a => a.HasActiveJobs()).Returns(false);
            ListWorkerJobsController listWorkerJobsController =
                new ListWorkerJobsController(mockedService.Object);
            var    result   = (ViewResult)listWorkerJobsController.Index();
            string toReturn = result.ViewData["Jobs"].ToString();

            Assert.That(toReturn == "<h2>You have no active jobs!</h2>");
        }
コード例 #3
0
        public void ReturnsCorrectlyWhenWorkerHasActiveJobs()
        {
            Mock <IListWorkerJobsService> mockedService =
                new Mock <IListWorkerJobsService>();

            mockedService.Setup(a => a.IsWorker()).Returns(true);
            mockedService.Setup(a => a.HasActiveJobs()).Returns(true);
            mockedService.Setup(a => a.ActiveJobs()).Returns(this.GenerateJobs());
            ListWorkerJobsController listWorkerJobsController =
                new ListWorkerJobsController(mockedService.Object);
            var    result   = (ViewResult)listWorkerJobsController.Index();
            string toReturn = result.ViewData["Jobs"].ToString();

            Assert.That(
                toReturn.Contains
                    ("<a href=\"/WorkerActiveJob/Index/1\">asdf</a>") &&
                toReturn.Contains
                    ("<a href=\"/WorkerActiveJob/Index/5\">agdfghrht</a>")
                );
        }