Пример #1
0
        //TODO: (SD) set parameters method is rudimentary, subject ti refactor
        public virtual void SetParameters
            (
            ProcessorConfiguration config
            )
        {
            ErrorTrap.AddRaisableAssertion<ArgumentNullException>(config != null, "config != null");
            configuration = config;
// ReSharper disable PossibleNullReferenceException - Checked by ErrorTrap
            Name = config.Name;
// ReSharper restore PossibleNullReferenceException
            Description = config.Description;
        }
Пример #2
0
        public void CancelPrioritySlotReservationTest()
        {
            var producer = new MockProducer();
            var target = new Producer_Accessor(new PrivateObject(producer));

            var configuration = new ProcessorConfiguration
            {
                Count = 1,
                Description = "Test producer",
                Enabled = true,
                Name = "TestProducer",
                Priority = SubmissionPriority.High
            };
            //TODO: (SD) set parameters method is rudimentary, subject ti refactor
            target.SetParameters(configuration);

            var slots = new PrioritySlotsCountCollection();
            slots.Add(new PrioritySlotsConfiguration { Count = 2, SubmissionPriority = SubmissionPriority.Normal, Timeout = -1 });

            target.StateData = new ProcessingStateData(new WorkItemSlotsConfiguration
            {
                Name = "Test",
                Description = "Test description",
                PrioritySlotCounts = slots
            });

            target.ReservePrioritySlot(SubmissionPriority.Normal);
            Assert.AreEqual(1, target.RetrievedItems.Counters[SubmissionPriority.Normal].SyncValue);
   
            target.CancelPrioritySlotReservation(SubmissionPriority.Normal);
            Assert.AreEqual(0, target.RetrievedItems.Counters[SubmissionPriority.Normal].SyncValue);

        }
Пример #3
0
        //[TestMethod]
        //[DeploymentItem("Tools.Coordination.dll")]
        public void ProcessRetrievedWorkItemWithBlockAndStopTest()
        {
            var producer = new MockProducer();
            var target = new Producer_Accessor(new PrivateObject(producer));

            var configuration = new ProcessorConfiguration
            {
                Count = 1,
                Description = "Test producer",
                Enabled = true,
                Name = "TestProducer",
                Priority = SubmissionPriority.High
            };
            //TODO: (SD) set parameters method is rudimentary, subject ti refactor
            target.SetParameters(configuration);

            var slots = new PrioritySlotsCountCollection();
            slots.Add(new PrioritySlotsConfiguration { Count = 2, SubmissionPriority = SubmissionPriority.Normal, Timeout = -1 });

            target.StateData = new ProcessingStateData(new WorkItemSlotsConfiguration
            {
                Name = "Test",
                Description = "Test description",
                PrioritySlotCounts = slots
            });

            target.ReservePrioritySlot(SubmissionPriority.Normal);
            target.ReservePrioritySlot(SubmissionPriority.Normal);
            target.ReservePrioritySlot(SubmissionPriority.Normal);

            producer.Stop();
        }
Пример #4
0
        public void SetParametersTest()
        {
            var producer = new MockProducer();
            var target = new Producer_Accessor(new PrivateObject(producer));

            const string name = "TestProducer";
            const string description = "TestProducer description";

            var config = new ProcessorConfiguration
                                    {
                                        Count = 1,
                                        Description = description,
                                        Enabled = true,
                                        Name = name,
                                        Priority = SubmissionPriority.High
                                    };
            producer.SetParameters(config);

            Assert.AreEqual(name, producer.Name);
            Assert.AreEqual(description, producer.Description);
            Assert.AreEqual(SubmissionPriority.High, target.PriorityScope);
        }
Пример #5
0
        public void StartInternalTest()
        {
            var producer = new MockProducer();
            var target = new Producer_Accessor(new PrivateObject(producer));

            var configuration = new ProcessorConfiguration
            {
                Count = 1,
                Description = "Test producer",
                Enabled = true,
                Name = "TestProducer",
                Priority = SubmissionPriority.High
            };
            //TODO: (SD) set parameters method is rudimentary, subject ti refactor
            target.SetParameters(configuration);

            target.StateData = new ProcessingStateData(new WorkItemSlotsConfiguration());
            //TODO: (SD) Return to the scenario when producer will be throwing errors in the
            // GetNextWorkItem method.
            producer.Start();
            Thread.Sleep(2000);
            producer.Stop();
        }
Пример #6
0
        public void ConfigurationTest()
        {
            Producer_Accessor target = CreateProducer_Accessor();
            var configuration = new ProcessorConfiguration
                                    {
                                        Count = 1,
                                        Description = "Test producer",
                                        Enabled = true,
                                        Name = "TestProducer",
                                        Priority = SubmissionPriority.High
                                    };
            //TODO: (SD) set parameters method is rudimentary, subject ti refactor
            target.SetParameters(configuration);

            Assert.AreEqual(configuration, target.Configuration);
        }