def test_execute(self): #Case 1 event time at 0.0 #------------------------------------------------------------------------------ a = CounterSim() a.setup(1) b = CounterEvent(0) self.assertEqual(b.time(),0.0) p = b.execute(a) #get the real list object l = a.getset().getset() #Check wether it has been rescheduled correclty self.assertEqual(b.time(),2.0) #Check the thing it retunrs(It prints out) self.assertEqual('The event time is 0.0',p) #CHeck whether it has been reinserted back to the events collection correctly after rescheduleing self.assertTrue(l[1] is b) #Case 2 event time at 2.0 #------------------------------------------------------------------------------ a = CounterSim() a.setup(1) a.setup(13) b = CounterEvent(2.0) self.assertEqual(b.time(),2.0) p = b.execute(a) #get the real list object l = a.getset().getset() self.assertEqual(b.time(),4.0) self.assertEqual('The event time is 2.0',p) self.assertTrue(l[1] is b) #Case 3 event time at 14.0 (So won't be reschedued and reinserted) #------------------------------------------------------------------------------ a = CounterSim() a.setup(1) a.setup(13) b = CounterEvent(14.0) self.assertEqual(b.time(),14.0) p = b.execute(a) #get the real list object l = a.getset().getset() self.assertEqual(b.time(),14.0) self.assertEqual('The event time is 14.0',p) self.assertTrue(b not in l)
def test_SetUP(self): ''' Testing Setup method''' a = CounterSim() a.setup(3) a.setup(5) a.setup(1) self.assertEqual(str(a.getset()),'[<Event: 1.0>*, <Event: 3.0>, <Event: 5.0>]')
def test_DoallEvents_one_Bigger_than_10(self): a = CounterSim() a.setup(0) print('********************************************************') print('##TEST for one event (time is bigger than 10)') print('##Initial event: <Event: 20.0>') print('Pay attention here to check whether the simulation driver is doing the rihgt thing') a.doAllEvents()
def test_DoallEvents_one_initial_envent(self): '''Testing DoallEventsMethod''' a = CounterSim() a.setup(0) print('********************************************************') print('##TEST for one event (time is less than 10)') print('##Initial Event: <Event: 0.0>') print('Pay attention here to check whether the simulation driver is doing the rihgt thing') a.doAllEvents()
def test_SetUP(self): ''' Testing Setup method''' a = CounterSim() a.setup(3) a.setup(5) a.setup(1) self.assertEqual(str(a.getset()), '[<Event: 1.0>*, <Event: 3.0>, <Event: 5.0>]')
def test_execute(self): #Case 1 event time at 0.0 #------------------------------------------------------------------------------ a = CounterSim() a.setup(1) b = CounterEvent(0) self.assertEqual(b.time(), 0.0) p = b.execute(a) #get the real list object l = a.getset().getset() #Check wether it has been rescheduled correclty self.assertEqual(b.time(), 2.0) #Check the thing it retunrs(It prints out) self.assertEqual('The event time is 0.0', p) #CHeck whether it has been reinserted back to the events collection correctly after rescheduleing self.assertTrue(l[1] is b) #Case 2 event time at 2.0 #------------------------------------------------------------------------------ a = CounterSim() a.setup(1) a.setup(13) b = CounterEvent(2.0) self.assertEqual(b.time(), 2.0) p = b.execute(a) #get the real list object l = a.getset().getset() self.assertEqual(b.time(), 4.0) self.assertEqual('The event time is 2.0', p) self.assertTrue(l[1] is b) #Case 3 event time at 14.0 (So won't be reschedued and reinserted) #------------------------------------------------------------------------------ a = CounterSim() a.setup(1) a.setup(13) b = CounterEvent(14.0) self.assertEqual(b.time(), 14.0) p = b.execute(a) #get the real list object l = a.getset().getset() self.assertEqual(b.time(), 14.0) self.assertEqual('The event time is 14.0', p) self.assertTrue(b not in l)
def test_DoallEvents_one_Bigger_than_10(self): a = CounterSim() a.setup(0) print('********************************************************') print('##TEST for one event (time is bigger than 10)') print('##Initial event: <Event: 20.0>') print( 'Pay attention here to check whether the simulation driver is doing the rihgt thing' ) a.doAllEvents()
def test_DoallEvents_one_initial_envent(self): '''Testing DoallEventsMethod''' a = CounterSim() a.setup(0) print('********************************************************') print('##TEST for one event (time is less than 10)') print('##Initial Event: <Event: 0.0>') print( 'Pay attention here to check whether the simulation driver is doing the rihgt thing' ) a.doAllEvents()
def test_now_not_emp(self): ''' Testing Now Method when not start from initial value''' a = CounterSim() a.setup(4) print('********************************************************') print('********************************************************') print('********************************************************') print('********************************************************') print('********************************************************') print('Not A part of DoAllEvents TEST') a.doAllEvents() t = a.now() self.assertEqual(10.0, t)
def test_now_not_emp(self): ''' Testing Now Method when not start from initial value''' a = CounterSim() a.setup(4) print('********************************************************') print('********************************************************') print('********************************************************') print('********************************************************') print('********************************************************') print('Not A part of DoAllEvents TEST') a.doAllEvents() t = a.now() self.assertEqual(10.0,t)
def test_DoAllEvents_multiple_some_bigger_than_10(self): '''Testing DoallEventsMethod''' a = CounterSim() a.setup(0) a.setup(2.4) a.setup(5.4) a.setup(2) a.setup(3) a.setup(11.4) a.setup(15.31415926) print('********************************************************') print('##TEST for Multiple events_all (times of some bigger than time 10) ') print('##Initial events: <Event: 0.0> <Event: 2.0> <Event: 2.4> <Event: 3.0> <Event: 5.4> <Event: 11.4> <Event: 15.1415926>') print('Pay attention here to check whether the simulation driver is doing the rihgt thing') a.doAllEvents()
def test_DoAllEvents_multiple_some_bigger_than_10(self): '''Testing DoallEventsMethod''' a = CounterSim() a.setup(0) a.setup(2.4) a.setup(5.4) a.setup(2) a.setup(3) a.setup(11.4) a.setup(15.31415926) print('********************************************************') print( '##TEST for Multiple events_all (times of some bigger than time 10) ' ) print( '##Initial events: <Event: 0.0> <Event: 2.0> <Event: 2.4> <Event: 3.0> <Event: 5.4> <Event: 11.4> <Event: 15.1415926>' ) print( 'Pay attention here to check whether the simulation driver is doing the rihgt thing' ) a.doAllEvents()