Exemplo n.º 1
0
        public void DI_Semantics_Allow_Overridden_Coordinator()
        {
            var queueName = QueueNameHelper.CreateQueueName();
            var container = new SimpleInjector.Container();

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

            /*var executor = new HardInjectedJobExecutorShell(() => new JobQueueLayerActor(jobStore),
            *   () => new JobWorkerActor(new DefaultJobExecutor(new DefaultContainerFactory())), null);*/
            jobStore.AddJob((DIShellMockJob m) => m.DoThing(nameof(DI_Semantics_Allow_Overridden_Coordinator), 0), null, null, queueName);
            executor.StartJobQueue(queueName, 5, 1, 1);
            SpinWait.SpinUntil(() => false, TimeSpan.FromSeconds(8));
            Xunit.Assert.True(
                DIShellMockJob.MyCounter.ContainsKey(nameof(DI_Semantics_Allow_Overridden_Coordinator)));
            Xunit.Assert.Equal(1, OverriddenJobCoordinator.Succeeded);
        }
Exemplo n.º 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);
        }