コード例 #1
0
 public CarService(ICarRepository carRepository, ICarValidator carValidator)
 {
     if (carRepository == null)
     {
         throw new ArgumentException("Car repository is missing");
     }
     _carRepository = carRepository;
     _carValidator  = carValidator; //later check for null
 }
コード例 #2
0
 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();
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 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;
 }
コード例 #5
0
 public CarService(ICarRepository carRepository,
                   ICarValidator carValidator)
 {
     _carRepository = carRepository;
     _carValidator  = carValidator;
 }