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); }
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>"); }
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>") ); }