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));
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo n.º 9
0
 public void InputOfGateChangedAfterEventFired()
 {
     var envt = new EventStub(0);
 }