public void Test_DeleteTruckDriver_Return_HttpNotFound_When_TruckDriverRepo_Equal_Null() { // Arrange var truckDriver = MockTruckDriver(); var truckDriverRepository = new Mock <ITruckDriverRepository>(); truckDriverRepository.Setup(e => e.GetTruckDriverById(truckDriver.TruckDriverId)).Returns(truckDriver); var controller = new TruckDriverController(truckDriverRepository.Object); // Act var result = controller.DeleteTruckDriver(5) as ActionResult; var truckDriverRepoNull = new HttpNotFoundResult(); // Assert Assert.AreEqual(result.ToString(), truckDriverRepoNull.ToString()); }
public void Test_DeleteTruckDriver_Return_TruckDriver_And_ViewName_Correct() { // Arrange var truckDriver = MockTruckDriver(); var truckDriverRepository = new Mock <ITruckDriverRepository>(); truckDriverRepository.Setup(e => e.GetTruckDriverById(1)).Returns(truckDriver); var controller = new TruckDriverController(truckDriverRepository.Object); // Act var result = controller.DeleteTruckDriver(1) as ViewResult; var viewName = result.ViewName; // Assert Staff Id Null Assert.AreEqual(viewName, "DeleteTruckDriver"); }
public void Test_DeleteTruckDriver_Return_HttpBadRequest_When_TruckDriverId_Equal_Null() { // Arrange var truckDriver = new TruckDriver(); var truckDriverRepository = new Mock <ITruckDriverRepository>(); truckDriverRepository.Setup(e => e.GetTruckDriverById(null)).Returns(truckDriver); var controller = new TruckDriverController(truckDriverRepository.Object); // Act var result = controller.DeleteTruckDriver(null) as ActionResult; var truckDriverIdNull = new HttpStatusCodeResult(HttpStatusCode.BadRequest); // Assert Staff Id Null Assert.AreEqual(result.ToString(), truckDriverIdNull.ToString()); }