Exemplo n.º 1
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);

        }
Exemplo n.º 2
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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 4
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();
        }