Exemplo n.º 1
0
 public void Initialize()
 {
     DataProvider = new LocalDataProvider();
     SessionDefault = this.GetSession();
     Repository = new CollectRequestRepository(DataProvider);
     FakeScheduler = MockRepository.GenerateMock<IScheduler>();
     fakeProbeManager = MockRepository.GenerateMock<IProbeManager>();
     fakeScheduleController = MockRepository.GenerateMock<IScheduleController>();
     definitionFactory = new DefinitionDocumentFactory(DataProvider);
     fakeCollectAssembler = new CollectRequestAssembler(DataProvider);
     fakeResultAssembler = new CollectResultAssembler();
     fakePackageAssembler = new CollectPackageAssembler(DataProvider);
     CollectController = new CollectController(Repository, FakeScheduler, fakeScheduleController, fakeProbeManager, fakeCollectAssembler, fakeResultAssembler, fakePackageAssembler, definitionFactory);
 }
Exemplo n.º 2
0
        public CollectService()
        {
            var diContainer = new UnityContainer().CreateChildContainer();
            lock (ScheduleInitLock)
            {
                var scheduler = new Quartz.Impl.StdSchedulerFactory().GetScheduler();
                if (ScheduleController == null)
                {
                    SchedulerContainer = diContainer.CreateChildContainer();
                    scheduler.JobFactory = new UnityJobFactory(SchedulerContainer);
                    ScheduleController = new ScheduleController(scheduler);
                    ScheduleController.ReschedulingAlreadyExecuted = false;
                }

                diContainer.RegisterType<IDataProvider, DataProvider>(new ContainerControlledLifetimeManager());
                diContainer.RegisterType<ICollectRequestRepository, CollectRequestRepository>(new ContainerControlledLifetimeManager());
                diContainer.RegisterType<IProbeManager, ProbeManager>();
                diContainer.RegisterType<ICollectRequestAssembler, CollectRequestAssembler>(new ContainerControlledLifetimeManager());
                diContainer.RegisterType<ICollectPackageAssembler, CollectPackageAssembler>(new ContainerControlledLifetimeManager());
                diContainer.RegisterType<ICollectResultAssembler, CollectResultAssembler>(new ContainerControlledLifetimeManager());
                diContainer.RegisterType<IDefinitionDocumentFactory, DefinitionDocumentFactory>(new ContainerControlledLifetimeManager());
                diContainer.RegisterInstance<IScheduler>(scheduler);
                diContainer.RegisterInstance<IScheduleController>(ScheduleController);

                CollectController = diContainer.Resolve<CollectController>();
            }
        }