Ejemplo n.º 1
0
        public void HasWorkTest()
        {
            var q = new WorkItemQueue("test", true, ApartmentState.MTA);

            _shift.AddQueue(q);
            Assert.False(_shift.HasWork, "Should not have work initially");
            q.Enqueue(Fakes.GetWorkItem(this, "Test1"));
            Assert.That(_shift.HasWork, "Should have work after enqueue");
            _shift.Start();
            Assert.That(_shift.HasWork, "Should have work after starting");
        }
        /// <summary>
        /// Dispatch a single work item.
        /// </summary>
        /// <param name="work">The item to dispatch</param>
        public void Dispatch(WorkItem work)
        {
            log.Debug("Enqueuing WorkItem for {0}", work.Test.FullName);
#if STA_QUEUE
            if (work.TargetApartment == ApartmentState.STA)
            {
                _staQueue.Enqueue(work);
            }
            else
#endif
            _readyQueue.Enqueue(work);

            ++_itemsDispatched;
        }
Ejemplo n.º 3
0
        public void BusyExecuteIdleEventsCalledInSequence()
        {
            StringBuilder sb   = new StringBuilder();
            FakeWorkItem  work = Fakes.GetWorkItem(this, "FakeMethod");

            _worker.Busy  += (s, ea) => { sb.Append("Busy"); };
            work.Executed += (s, ea) => { sb.Append("Exec"); };
            _worker.Idle  += (s, ea) => { sb.Append("Idle"); };

            _queue.Enqueue(work);
            _worker.Start();
            _queue.Start();

            Assert.That(() => sb.ToString(), Is.EqualTo("BusyExecIdle").After(200));
        }
 public void HasWorkTest()
 {
     var q = new WorkItemQueue("test");
     _shift.AddQueue(q);
     Assert.False(_shift.HasWork, "Should not have work initially");
     q.Enqueue(Fakes.GetWorkItem(this, "Test1"));
     Assert.That(_shift.HasWork, "Should have work after enqueue");
     _shift.Start();
     Assert.That(_shift.HasWork, "Should have work after starting");
 }
Ejemplo n.º 5
0
 private void EnqueueWorkItems()
 {
     _queue.Enqueue(Fakes.GetWorkItem(this, "Test1"));
     _queue.Enqueue(Fakes.GetWorkItem(this, "Test2"));
     _queue.Enqueue(Fakes.GetWorkItem(this, "Test3"));
 }