コード例 #1
0
 public ScooterService(ICarRentalUnitOfWork unitOfWork,
                       ScooterMapper scooterMapper,
                       IDomainEventPublisher domainEventPublisher)
 {
     this._unitOfWork           = unitOfWork;
     this._scooterMapper        = scooterMapper;
     this._domainEventPublisher = domainEventPublisher;
 }
コード例 #2
0
        public SimpleTestContainer()
        {
            // domain event publisher
            var domainEventPublisher = new SimpleEventPublisher();

            // infrastructure service
            var emaildispatcher = new EmailDispatcher();

            // event listeners
            var driverCreatedEventListener = new DriverCreatedEventListener();

            domainEventPublisher.Subscribe <DriverCreatedEvent>(driverCreatedEventListener);

            //unitOfWork
            var unitOfWork = new MemoryCarRentalUnitOfWork(
                new MemoryRepository <Driver>(),
                new MemoryRepository <Car>(),
                new MemoryRepository <Rental>(),
                new MemoryRepository <Scooter>());

            // factories
            var rentalFactory      = new RentalFactory(domainEventPublisher);
            var carFactory         = new CarFactory(domainEventPublisher);
            var freeMinutesFactory = new FreeMinutesFactory();

            // mappers
            var carMapper     = new CarMapper();
            var driverMapper  = new DriverMapper();
            var scooterMapper = new ScooterMapper();
            var rentalMapper  = new RentalMapper();

            this.CarService = new CarService(
                unitOfWork,
                carMapper,
                domainEventPublisher);

            this.ScooterService = new ScooterService(
                unitOfWork,
                scooterMapper,
                domainEventPublisher);

            this.DriverService = new DriverService(
                unitOfWork,
                driverMapper,
                domainEventPublisher);

            this.RentalService = new RentalService(
                unitOfWork,
                rentalFactory,
                rentalMapper,
                freeMinutesFactory,
                domainEventPublisher);
        }