Example #1
0
        public void JobExecutorShell_Will_Execute_Jobs()
        {
            var queueName = QueueNameHelper.CreateQueueName();
            var container = new SimpleInjector.Container();

            container.Register <IContainerFactory, TestSimpleInjectorContainerFactory>();
            container.Register <ISqlDbJobQueueTableConfiguration, SqlDbJobQueueDefaultTableConfiguration>();
            container.Register <IJobAdderQueueTableResolver, DefaultJobAdderQueueTableResolver>();
            container.Register <SQLiteJobQueueDataConnectionFactory>(() => new SQLiteJobQueueDataConnectionFactory(UnitTestTableHelper.connString));
            container.Register <IJobQueueManager, SQLiteJobQueueManager>();
            container.Register <IJobQueueAdder, SQLiteJobQueueAdder>();
            container.Register <IJobTypeResolver, NullOnMissingTypeJobTypeResolver>();
            container.Register <IJobExecutor, DefaultJobExecutor>();
            container.Register <JobQueueLayerActor>();
            container.Register <JobWorkerActor>();
            container.Register <JobQueueCoordinator>();
            var jobStore = (IJobQueueAdder)container.GetInstance(typeof(IJobQueueAdder));
            var executor = new DependencyInjectedJobExecutorShell(
                (system) => new SimpleInjectorDependencyResolver(container, system),
                null);

            container.Verify();

            /*var executor = new HardInjectedJobExecutorShell(() => new JobQueueLayerActor(jobStore),
            *   () => new JobWorkerActor(new DefaultJobExecutor(new DefaultContainerFactory())), null);*/
            executor.StartJobQueue(queueName, 5, 1, 1);
            jobStore.AddJob((DIShellMockJob m) => m.DoThing(nameof(JobExecutorShell_Will_Execute_Jobs), 1), null, null, queueName);
            SpinWait.SpinUntil(() => false, TimeSpan.FromSeconds(8));
            Xunit.Assert.True(DIShellMockJob.MyCounter.ContainsKey(nameof(JobExecutorShell_Will_Execute_Jobs)));
        }
Example #2
0
        public void JobShell_Can_Start()
        {
            var queueName = QueueNameHelper.CreateQueueName();
            var container = new SimpleInjector.Container();

            container.Register <IContainerFactory, TestSimpleInjectorContainerFactory>();
            container.Register <ISqlDbJobQueueTableConfiguration, SqlDbJobQueueDefaultTableConfiguration>();
            container.Register <IJobAdderQueueTableResolver, DefaultJobAdderQueueTableResolver>();
            container.Register <SQLiteJobQueueDataConnectionFactory>(() => new SQLiteJobQueueDataConnectionFactory(UnitTestTableHelper.connString));
            container.Register <IJobQueueManager, SQLiteJobQueueManager>();
            container.Register <IJobQueueAdder, SQLiteJobQueueAdder>();
            container.Register <IJobExecutor, MockJobSuccessExecutor>();
            container.Register <JobQueueLayerActor>();
            container.Register <JobWorkerActor>();
            //container.Verify();
            // HardInjectedJobExecutorShell(() => new JobQueueLayerActor(jobStore),
            //() => new JobWorkerActor(new MockJobSuccessExecutor()), null);
            var executor = new DependencyInjectedJobExecutorShell(
                (system) => new SimpleInjectorDependencyResolver(container, system),
                null);

            executor.StartJobQueue(queueName, 5, 1);
        }