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

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