public void Test_FormEditJobAssignment_Return_BadRequest_When_JobId_Is_Null() { // Arrange var jobAssignmentRepository = new Mock <IJobAssignmentRepository>(); var truckDriverRepository = new Mock <ITruckDriverRepository>(); var controller = new JobAssignmentController(jobAssignmentRepository.Object, truckDriverRepository.Object); // Act var result = controller.FormEditJobAssignment(null) as ActionResult; var jobNull = new HttpStatusCodeResult(HttpStatusCode.BadRequest); // Assert Assert.AreEqual(result.ToString(), jobNull.ToString()); }
public void Test_FormEditJobAssignment_Return_HttpNotFound_When_JobRepo_Return_Null() { // Arrange var job = MockJob(); var jobAssignmentRepository = new Mock <IJobAssignmentRepository>(); jobAssignmentRepository.Setup(e => e.GetJobAssignmentById(job.JobAssignmentId)).Returns(job); var truckDriverRepository = new Mock <ITruckDriverRepository>(); var controller = new JobAssignmentController(jobAssignmentRepository.Object, truckDriverRepository.Object); // Act var result = controller.FormEditJobAssignment(5) as ActionResult; var jobRepoNull = new HttpNotFoundResult(); // Assert Assert.AreEqual(result.ToString(), jobRepoNull.ToString()); }
public void Test_FormEditJobAssignment_Return_Job_And_View_When_Job_Exist() { // Arrange var job = MockJob(); var jobAssignmentRepository = new Mock <IJobAssignmentRepository>(); jobAssignmentRepository.Setup(e => e.GetJobAssignmentById(job.JobAssignmentId)).Returns(job); var truckDriverRepository = new Mock <ITruckDriverRepository>(); var controller = new JobAssignmentController(jobAssignmentRepository.Object, truckDriverRepository.Object); // Act var result = controller.FormEditJobAssignment(job.JobAssignmentId) as ViewResult; var viewName = result.ViewName; var model = result.Model as FormJobAssignmentViewModel; // Assert Assert.AreEqual(viewName, "FormEditJobAssignment"); Assert.IsNotNull(model); }