Esempio n. 1
0
        public void TestConcurrentListenersSequentially(int numListeners)
        {
            _eb.RegisterEvent(_eventControl);
            _eb.RegisterEvent(_eventSound);
            _eb.RegisterEvent(_eventControl);

            List <SimpleEventProcessor> listOfProcessors = new List <SimpleEventProcessor>();

            for (int iter = 0; iter < numListeners; iter++)
            {
                var processor = new SimpleEventProcessor();
                listOfProcessors.Add(processor);
                _eb.Subscribe(GameEventType.ControlEvent, processor);
                _eb.Subscribe(GameEventType.SoundEvent, processor);
            }

            _eb.ProcessEventsSequentially();

            Assert.That(_simpleEventProcessor.EventCounterControl == 2);
            Assert.That(_simpleEventProcessor.EventCounterSound == 1);
            foreach (var processor in listOfProcessors)
            {
                Assert.That(processor.EventCounterControl == 2);
                Assert.That(processor.EventCounterSound == 1);
            }
        }
Esempio n. 2
0
        public void SetupEventBusForTests()
        {
            _eb = new GameEventBus();
            _eb.InitializeEventBus(_registeredEvents);

            _simpleEventProcessor = new SimpleEventProcessor();
            _eb.Subscribe(GameEventType.ControlEvent, _simpleEventProcessor);
            _eb.Subscribe(GameEventType.SoundEvent, _simpleEventProcessor);

            _eventControl = new GameEvent {
                EventType  = GameEventType.ControlEvent,
                From       = this,
                Message    = "Test2",
                StringArg1 = "test",
                StringArg2 = "test"
            };
            _eventSound = new GameEvent {
                EventType  = GameEventType.SoundEvent,
                From       = this,
                Message    = "Test2",
                StringArg1 = "test",
                StringArg2 = "test"
            };
        }