public void WhenTruckInspectionPassesButTrackCountReachedLimit() { //arrange truck = new Truck { TowStrap = true, LiftHeight = 4 }; //act var allowed = truck.AllowOnTrack(5); //assert Assert.IsFalse(allowed); }
public void WhenTruckHasStrapAndLiftedMoreThanFiveInchesInspectionFails() { //arrange truck = new Truck { TowStrap = true, LiftHeight = 6 }; //act var allowed = truck.AllowOnTrack(0); //assert Assert.IsFalse(allowed); }
public void WhenTruckHasStrapAndLiftedLessThanOrEqualToFiveInchesInspectionPasses() { //arrange truck = new Truck { TowStrap = true, LiftHeight = 4 }; //act var allowed = truck.AllowOnTrack(0); //assert Assert.IsTrue(allowed); }
public ActionResult AddVehicle(AddVehicleViewModel model) { if (ModelState.IsValid) { _raceTrackRepository = new RaceTrackRepository(dbContext); if (model.Vehicle.VehicleType == VehicleType.Truck) { Truck newTruck = new Truck { TowStrap = model.Vehicle.TowStrap, LiftHeight = model.TruckLiftHeight, VehicleType = model.Vehicle.VehicleType }; if (newTruck.AllowOnTrack(_raceTrackRepository.GetVehicleCount())) { _raceTrackRepository.Add(newTruck); } else { ModelState.AddModelError("", "Not allowed"); } } if (model.Vehicle.VehicleType == VehicleType.Car) { Car newCar = new Car { TowStrap = model.Vehicle.TowStrap, TireWear = model.CarTireWear, VehicleType = model.Vehicle.VehicleType }; if (newCar.AllowOnTrack(_raceTrackRepository.GetVehicleCount())) { _raceTrackRepository.Add(newCar); } else { ModelState.AddModelError("", "Not allowed"); } } } return(RedirectToAction("Index", "Home")); }