Exemple #1
0
        public void TestBaseFunctionality()
        {
            Model model = new Model();

            IExecutive exec = model.Executive;
            DateTime   now  = DateTime.Now;
            DateTime   when;
            double     priority;

            m_des = new DetachableEventSynchronizer(model);

            for (int i = 0; i < NUM_EVENTS; i++)
            {
                when     = new DateTime(now.Ticks + m_random.Next());
                priority = m_random.NextDouble();
                Debug.WriteLine("Primary requesting event service for " + when + ", at priority " + priority);
                object userData = null;
                if (m_random.Next(5) < 2)
                {
                    ISynchChannel isc = m_des.GetSynchChannel(priority);
                    userData = isc;
                    Debug.WriteLine("Creating synchronized event for time " + when);
                    _synchronized++;
                }
                exec.RequestEvent(new ExecEventReceiver(MyExecEventReceiver), when, priority, userData, ExecEventType.Detachable);
                _submitted++;
            }

            Assert.IsTrue(_submitted > 0, "There are no events submitted");
            Assert.IsTrue(_synchronized > 0, "There are no events synchronized");
            Assert.IsTrue(_secondary == 0, "There cannot be secondary events submitted yet");

            exec.Start();

            Assert.IsTrue(_submitted == 0, "Not all submitted events had been fired");
            Assert.IsTrue(_synchronized == 0, "Not all synchronized events had been fired");
            Assert.IsTrue(_secondary > 0, "There has not been a secondary events submitted");
        }
Exemple #2
0
 /// <summary>
 /// Creates a new instance of the <see cref="T:SynchChannel"/> class.
 /// </summary>
 /// <param name="ds">The <see cref="Highpoint.Sage.SimCore.DetachableEventSynchronizer"/>.</param>
 /// <param name="sortKey">The sort key.</param>
 public SynchChannel(DetachableEventSynchronizer ds, IComparable sortKey)
 {
     m_ds      = ds;
     m_sortKey = sortKey;
 }