public void NotEmptyQueueHasEventsAtTheTimeOfEvent()
        {
            var eventQueue = new EventQueue();
            var eventStub  = new EventStub(0);

            eventQueue.AddEvent(eventStub);
            Assert.IsTrue(eventQueue.HasMoreEventsFor(0));
        }
        public void NotEmptyQueueDoesNotHaveEventsAtTheTimeOfEvent()
        {
            var eventQueue = new EventQueue();
            var eventStub  = new EventStub(0);

            eventQueue.AddEvent(eventStub);
            Assert.IsFalse(eventQueue.HasMoreEventsFor(1));
        }
        public void EventFromQueueIsTheSameAsEventAddedToQueue()
        {
            var eventQueue = new EventQueue();
            var eventStub  = new EventStub(0);

            eventQueue.AddEvent(eventStub);
            Assert.AreSame(eventStub, eventQueue.GetNextEventFor(0));
        }
Esempio n. 4
0
        public void ProcessesAddedEvents()
        {
            var simulation = new Simulation(0);
            var evnt       = new EventStub(0);

            simulation.AddEvent(evnt);
            simulation.SimulateNextTimeframe();
            Assert.IsTrue(evnt.IsProcesed);
        }
Esempio n. 5
0
        public void CannotHaveEventsWithTriggerBiggerThanMaxTime()
        {
            var simulation = new Simulation(0);
            var evnt       = new EventStub(1);

            simulation.AddEvent(evnt);
            simulation.SimulateNextTimeframe();
            Assert.Catch <SimulationException>(simulation.SimulateNextTimeframe);
        }
        public void ReturnsNullWhenThereIsNoEventForTheGivenTime()
        {
            var eventQueue = new EventQueue();
            var eventStub1 = new EventStub(0);

            eventQueue.AddEvent(eventStub1);
            eventQueue.GetNextEventFor(0);
            Assert.IsNull(eventQueue.GetNextEventFor(0));
        }
        public void ReturnsEventsInProperOrder()
        {
            var eventQueue = new EventQueue();
            var eventStub1 = new EventStub(0);
            var eventStub2 = new EventStub(0);

            eventQueue.AddEvent(eventStub1);
            eventQueue.AddEvent(eventStub2);
            Assert.AreSame(eventStub1, eventQueue.GetNextEventFor(0));
            Assert.AreSame(eventStub2, eventQueue.GetNextEventFor(0));
        }
Esempio n. 8
0
        public void ProcessesAddedEventsInRightOrderForTheSameTime()
        {
            var simulation = new Simulation(1);
            var evnt1      = new EventStub(1);
            var evnt2      = new EventStub(0);

            simulation.AddEvent(evnt1);
            simulation.AddEvent(evnt2);
            simulation.SimulateNextTimeframe();
            Assert.IsTrue(evnt2.IsProcesed);
            Assert.IsFalse(evnt1.IsProcesed);
            simulation.SimulateNextTimeframe();
            Assert.IsTrue(evnt1.IsProcesed);
            Assert.IsTrue(evnt2.IsProcesed);
        }
Esempio n. 9
0
 public void InputOfGateChangedAfterEventFired()
 {
     var envt = new EventStub(0);
 }