public CarService(ICarRepository carRepository, ICarValidator carValidator) { if (carRepository == null) { throw new ArgumentException("Car repository is missing"); } _carRepository = carRepository; _carValidator = carValidator; //later check for null }
public CarValidatorTest() { carRepoMock = new Mock <ICarRepository>(); modelRepoMock = new Mock <IModelRepository>(); carRepoMock.Setup(repo => repo.ReadAllCars()).Returns(() => cars); modelRepoMock.Setup(repo => repo.ReadModelById(It.IsAny <int>())).Returns((int id) => models.FirstOrDefault(c => c.ModelId == id)); carRepoMock.Setup(repo => repo.ReadCarById(It.IsAny <int>())).Returns((int id) => cars.FirstOrDefault(c => c.CarId == id)); validator = new CarValidator(modelRepoMock.Object, carRepoMock.Object); car = new Car(); }
internal static Car Create(CreateCarCommand command, ICarValidator validator) { var car = new Car(command.Make, command.Model, command.Engine, command.Doors, command.Wheels, command.BodyType); validator.Validate(car); return(car); }
public CarController(ICarListModelBuilder carListModelBuilder, ICarItemModelBuilder carItemModelBuilder, ICarEditModelBuilder carEditModelBuilder, ICarValidator carValidator, ICarFormHandler carFormHandler, IWorkSelectListModelBuilder workSelectListModelBuilder, ICarDeleteHandler carDeleteHandler) { this.carListModelBuilder = carListModelBuilder; this.carItemModelBuilder = carItemModelBuilder; this.carEditModelBuilder = carEditModelBuilder; this.carValidator = carValidator; this.carFormHandler = carFormHandler; this.workSelectListModelBuilder = workSelectListModelBuilder; this.carDeleteHandler = carDeleteHandler; }
public CarService(ICarRepository carRepository, ICarValidator carValidator) { _carRepository = carRepository; _carValidator = carValidator; }