Esempio n. 1
0
        private SchedulerMethod Create(int workerCount, IWorkGroup workGroup = null)
        {
            var fixture             = new Fixture().Customize(new AutoNSubstituteCustomization());
            var cancelWork          = fixture.Create <IQueueCancelWork>();
            var workerConfiguration = fixture.Create <IWorkerConfiguration>();

            workerConfiguration.WorkerCount.Returns(workerCount);

            fixture.Inject(cancelWork);
            fixture.Inject(workerConfiguration);


            cancelWork.CancellationTokenSource.Returns(new CancellationTokenSource());
            cancelWork.StopTokenSource.Returns(new CancellationTokenSource());

            var stopWorker = fixture.Create <StopWorker>();

            fixture.Inject(stopWorker);

            IConsumerQueueAsync queue = fixture.Create <ConsumerQueueAsync>();
            var fixture2 = new Fixture().Customize(new AutoNSubstituteCustomization());

            fixture2.Inject(queue);

            var factoryFactory = fixture2.Create <ITaskFactoryFactory>();

            fixture2.Inject(factoryFactory);

            IConsumerQueueScheduler scheduler = fixture2.Create <Scheduler>();

            fixture2.Inject(scheduler);

            ATaskScheduler schedule = new CreateContainerTest.TaskSchedulerNoOp();

            schedule.Start();
            fixture2.Inject(schedule);
            var taskFactory = fixture2.Create <ITaskFactory>();

            taskFactory.Scheduler.Returns(schedule);
            fixture2.Inject(taskFactory);

            factoryFactory.Create().Returns(taskFactory);

            if (workGroup != null)
            {
                fixture2.Inject(workGroup);
            }

            var handler = fixture2.Create <SchedulerMessageHandler>();

            fixture2.Inject(handler);

            return(fixture2.Create <SchedulerMethod>());
        }
        private SchedulerMethod Create(int workerCount, IWorkGroup workgroup = null)
        {
            var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
            var cancelWork = fixture.Create<IQueueCancelWork>();
            var workerConfiguration = fixture.Create<IWorkerConfiguration>();
            workerConfiguration.WorkerCount.Returns(workerCount);

            fixture.Inject(cancelWork);
            fixture.Inject(workerConfiguration);


            cancelWork.CancellationTokenSource.Returns(new CancellationTokenSource());
            cancelWork.StopTokenSource.Returns(new CancellationTokenSource());

            var stopWorker = fixture.Create<StopWorker>();
            fixture.Inject(stopWorker);

            IConsumerQueueAsync queue = fixture.Create<ConsumerQueueAsync>();
            var fixture2 = new Fixture().Customize(new AutoNSubstituteCustomization());
            fixture2.Inject(queue);

            ITaskFactoryFactory factoryFactory = fixture2.Create<ITaskFactoryFactory>();
            fixture2.Inject(factoryFactory);

            IConsumerQueueScheduler scheulder = fixture2.Create<Scheduler>();
            fixture2.Inject(scheulder);

            ATaskScheduler schedule = new CreateContainerTest.TaskSchedulerNoOp();
            schedule.Start();
            fixture2.Inject(schedule);
            var taskFactory = fixture2.Create<ITaskFactory>();
            taskFactory.Scheduler.Returns(schedule);
            fixture2.Inject(taskFactory);

            factoryFactory.Create().Returns(taskFactory);

            if (workgroup != null)
                fixture2.Inject(workgroup);

            var handler = fixture2.Create<SchedulerMessageHandler>();
            fixture2.Inject(handler);

            return fixture2.Create<SchedulerMethod>();
        }