public void Test_DetailsTruckDriver_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.DetailsTruckDriver(5) as ActionResult; var truckDriverRepoNull = new HttpNotFoundResult(); // Assert Assert.AreEqual(result.ToString(), truckDriverRepoNull.ToString()); }
public void Test_DetailsTruckDriver_Return_HttpBadRequest_When_TruckDrivevrId_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.DetailsTruckDriver(null) as ActionResult; var truckDriverIdNull = new HttpStatusCodeResult(HttpStatusCode.BadRequest); // Assert Assert.AreEqual(result.ToString(), truckDriverIdNull.ToString()); }
public void Test_DetailsTruckDriver_Return_TruckDriver_And_ViewName_Correct() { // 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.DetailsTruckDriver(1) as ViewResult; var viewName = result.ViewName; var model = result.Model as TruckDriver; // Assert Assert.AreEqual(viewName, "DetailsTruckDriver"); Assert.IsNotNull(model); }