Ejemplo n.º 1
0
        private void GenerateRepositories()
        {
            _scope = new UnitOfWorkScope(new EFUnitOfWorkFactory(() => new DataContainer()));

            var client = new WebClientHelper(new HttpClient());
            _orderRepository = new OrderRepository(_scope, new OrderConfigurator(), new EFRepository<OrderItem>(_scope));
            _orderRepository.GetAll();
            _tr = new TransactionScope();

            var hostAdapter = new ExternalHostAddressHelper();
            var vesselService = new VesselDomainService(new BaseAntiCorruptionAdapter<Vessel, WarehouseDto>(
                                                            new VesselAntiCorruptionServiceWrapper(
                                                                client, hostAdapter),
                                                            new VesselAntiCorruptionMapper()),
                                                        new VesselRepository(_scope));
            var goodService = new GoodDomainService(new GoodAntiCorruptionAdapter(
                                                        new GoodAntiCorruptionServiceWrapper(client, hostAdapter),
                                                        new GoodAntiCorruptionMapper()), new EFRepository<Good>(_scope));

            var companyService = new CompanyDomainService(
                new CompanyAntiCorruptionAdapter(new CompanyAntiCorruptionServiceWrapper
                                                     (client, hostAdapter),
                                                 new CompanyAntiCorruptionMapper()),
                new CompanyRepository(_scope));

            var orderApplicationService = new OrderApplicationService(
                _orderRepository, _scope,
                new UserRepository(_scope),
                vesselService, goodService,
                new OrderFactory(new OrderCodeGenerator()
                                 , new OrderConfigurator()
                                 , new WorkflowRepository(_scope)),
                companyService,
                new OrderItemDomainService(new EFRepository<OrderItem>(_scope)),
                new OrderConfigurator());
            _approvalWorkFlowRepository = new WorkflowLogRepository(_scope);
            _approveFlowApplicationService = new ApproveFlowApplicationService(_scope, _approvalWorkFlowRepository,
                                                                               new WorkflowRepository(_scope));
        }
        public FuelReportTestObjectsContainer(UnitOfWorkScope unitOfWorkScope)
        {
            this.UnitOfWorkScope = unitOfWorkScope;

            var basicInfoDomainServiceObjects = new BasicInfoDomainServiceObjectsContainer(unitOfWorkScope);
            var scrapTestObjects = new ScrapTestObjectsContainer(this.UnitOfWorkScope);

            this.FuelReportConfigurator = new FuelReportConfigurator(new FuelReportStateFactory(),null,null);

            this.FuelReportRepository = new FuelReportRepository(this.UnitOfWorkScope, this.FuelReportConfigurator);

            var currencyRepository = new EFRepository<Currency>(this.UnitOfWorkScope);

            var currencyDomainService = new CurrencyDomainService(currencyRepository);

            this.VoyageDomainService = new VoyageDomainService(new VoyageRepository(this.UnitOfWorkScope), FuelReportRepository);

            this.VoyageLogDomainService = new VoyageLogDomainService(new VoyageLogRepository(this.UnitOfWorkScope));

            var inventoryOperationFactory = new InventoryOperationFactory();

            var inventoryOperationRepository = new InventoryOperationRepository(this.UnitOfWorkScope);
            var inventoryOperationDomainService = new InventoryOperationDomainService(inventoryOperationRepository, scrapTestObjects.ScrapDomainService);

            var orderConfigurator = new OrderConfigurator(
                new OrderStateFactory(
                    inventoryOperationDomainService
                    ));

            this.OrderDomainService = new OrderDomainService(new OrderRepository(this.UnitOfWorkScope, orderConfigurator, new EFRepository<OrderItem>(this.UnitOfWorkScope)));

            var client = new WebClientHelper(new HttpClient());
            var hostAdapter = new ExternalHostAddressHelper();

            var goodDomainService = new GoodDomainService(
                           new GoodAntiCorruptionAdapter(
                               new GoodAntiCorruptionServiceWrapper(client, hostAdapter),
                               new GoodAntiCorruptionMapper()),
                           new EFRepository<Good>(this.UnitOfWorkScope),
                           basicInfoDomainServiceObjects.CompanyDomainService, new EFRepository<GoodUnit>(this.UnitOfWorkScope));
            var inventoryManagementDomainService = new InventoryManagementDomainService(goodDomainService, currencyDomainService);

            this.FuelReportDomainService = new FuelReportDomainService(
                this.FuelReportRepository,
                this.VoyageDomainService,
                inventoryOperationDomainService,
                inventoryOperationRepository,
                inventoryOperationFactory,
                OrderDomainService,
                inventoryManagementDomainService
                ,
                new CharteringDomainService(new CharterInRepository(this.UnitOfWorkScope), new CharterOutRepository(this.UnitOfWorkScope)));

            this.WorkflowLogRepository = new WorkflowLogRepository(this.UnitOfWorkScope);

            //var inventoryOperationNotifier = new InventoryOperationNotifier();

            this.FuelReportApplicationService = null;
            //this.FuelReportApplicationService = new FuelReportApplicationService(
            //    this.UnitOfWorkScope,
            //    currencyDomainService,
            //    this.VoyageDomainService,
            //    FuelReportDomainService,
            //    new ApproveFlowApplicationService(this.UnitOfWorkScope, new WorkflowLogRepository(this.UnitOfWorkScope), new WorkflowRepository(this.UnitOfWorkScope), new OrderConfigurator(new OrderStateFactory(new InventoryOperationDomainService(new InventoryOperationRepository(this.UnitOfWorkScope), new ScrapDomainService(new ScrapRepository(this.UnitOfWorkScope, new ScrapConfigurator(new ScrapStateFactory(new ApprovableScrapDomainService(new VesselDomainService(new BaseAntiCorruptionAdapter<Vessel, WarehouseDto>(), ), )))), )), )), ));

            var goodMapper = new GoodToGoodDtoMapper(new CompanyGoodUnitToGoodUnitDtoMapper());
            var currencyMapper = new CurrencyToCurrencyDtoMapper();

            var companyDtoMapper = new BaseFacadeMapper<Company, CompanyDto>();
            var vesselDtoMapper = new VesselToVesselDtoMapper(companyDtoMapper);

            var fuelReportDetailMapper = new FuelReportDetailToFuelReportDetailDtoMapper(goodMapper, currencyMapper);

            var fuelReportToFuelReportDtoMapper = new FuelReportToFuelReportDtoMapper(
                fuelReportDetailMapper,
                vesselDtoMapper);

            this.VoyageFacadeService = new VoyageFacadeService(
                VoyageDomainService,
                new VoyageToVoyageDtoMapper(),
                FuelReportDomainService,
                fuelReportToFuelReportDtoMapper,
                inventoryOperationDomainService,
                new InventoryOperationToInventoryOperationDtoMapper(fuelReportDetailMapper),
                this.VoyageLogDomainService,
                new VoyageLogToVoyageLogDtoMapper(companyDtoMapper, vesselDtoMapper),
                goodMapper);
        }
Ejemplo n.º 3
0
        public void TestInitialize()
        {
            _scope = new UnitOfWorkScope(new EFUnitOfWorkFactory(() => new DataContainer()));

            basicInfoDomainServiceObjects = new BasicInfoDomainServiceObjectsContainer(_scope);
            scrapTestObjects = new ScrapTestObjectsContainer(_scope);

            var orderConfigurator = new OrderConfigurator
                (
                new OrderStateFactory
                    (
                    new InventoryOperationDomainService(new InventoryOperationRepository(_scope),
                        scrapTestObjects.ScrapDomainService)));

            var client = new WebClientHelper(new HttpClient());
            _orderRepository = new OrderRepository(_scope, orderConfigurator, new EFRepository<OrderItem>(_scope));
            _orderRepository.GetAll();
            _tr = new TransactionScope();

            var hostAdapter = new ExternalHostAddressHelper();
            var vesselService = new VesselInCompanyDomainService
                (new VesselInCompanyRepository(_scope, null), new VoyageRepository(_scope));
            //var goodPartyService = new GoodPartyAssignmentDomainService
            //    (new GoodPartyAssignmentAntiCorruptionAdapter(new GoodAssignmentAntiCorruptionServiceWrapper(client, hostAdapter)));
            var goodService = new GoodDomainService
                (
                new GoodAntiCorruptionAdapter(new GoodAntiCorruptionServiceWrapper(client, hostAdapter), new GoodAntiCorruptionMapper()),
                new EFRepository<Good>(_scope), basicInfoDomainServiceObjects.CompanyDomainService, new EFRepository<GoodUnit>(_scope));

            var goodUnitService = new GoodUnitDomainService
                (
                new BaseAntiCorruptionAdapter<GoodUnit, GoodUnitDto>
                    (new BaseAntiCorruptionServiceWrapper<GoodUnitDto>(client), new BaseAntiCorruptionMapper<GoodUnit, GoodUnitDto>()),
                new EFRepository<GoodUnit>(_scope));

            var companyService = new CompanyDomainService
                (
                new CompanyAntiCorruptionAdapter(new CompanyAntiCorruptionServiceWrapper(client, hostAdapter), new CompanyAntiCorruptionMapper()),
                new CompanyRepository(_scope));

            //_target = new OrderApplicationService
            //    (
            //    _orderRepository, _scope, new UserRepository(_scope), vesselService, goodService,
            //    new OrderFactory(new OrderCodeGenerator(_orderRepository), orderConfigurator, new WorkflowRepository(_scope)), companyService,
            //    new OrderItemDomainService(new EFRepository<OrderItem>(_scope)), orderConfigurator);

            //_sapid = FakeDomainService.GetCompanies().Single(c => c.Id == 1);
            //_imsemCo = FakeDomainService.GetCompanies().Single(c => c.Id == 3);
            //_hafiz = FakeDomainService.GetCompanies().Single(c => c.Id == 2);

            this.sapidVesselInCompany = FakeDomainService.GetVesselsInCompanies().First(c => c.CompanyId == 1);
            _sapidVessel2 = FakeDomainService.GetVesselsInCompanies().Last(c => c.CompanyId == 1);
            this.hafizVesselInCompany = FakeDomainService.GetVesselsInCompanies().First(c => c.CompanyId == 2);
            _good = FakeDomainService.GetGoods().Single(c => c.Id == 1);
            _good2 = FakeDomainService.GetGoods().Single(c => c.Id == 2);
            _unit = FakeDomainService.GetCompanyGoodUnits().Single(c => c.Id == 1);
            _unit2 = FakeDomainService.GetCompanyGoodUnits().Single(c => c.Id == 2);
            _unit3 = FakeDomainService.GetCompanyGoodUnits().Single(c => c.Id == 4);

            //_goodPartAssignment = FakeDomainService.GetGoodPartyAssignments().Single(c => c.Id == 1);
            //_goodPartAssignment2 = FakeDomainService.GetGoodPartyAssignments().Single(c => c.Id == 2);
        }