Beispiel #1
0
        public void EventManagerSubNotify()
        {
            LoadTextures();
            LoadFonts();
            var shooter = new Mock <Player>().Object;
            var victim  = new Mock <Player>().Object;

            var scoreboard = new Scoreboard();
            var killnotif  = new KillNotifier();

            var evtManager = PlayerEventManager.GetInstance();

            var evtData = new PlayerEventData();

            evtData.Shooter = shooter;
            evtData.Victim  = victim;

            evtManager.Subscribe(PlayerEventType.PlayerDead, killnotif);
            evtManager.Subscribe(PlayerEventType.KilledPlayer, scoreboard);

            evtManager.Notify(PlayerEventType.KilledPlayer, evtData);
            evtManager.Notify(PlayerEventType.PlayerDead, evtData);

            Assert.True(evtManager._listeners[PlayerEventType.PlayerDead].Count == 1 && evtManager._listeners[PlayerEventType.KilledPlayer].Count == 1);
        }
Beispiel #2
0
        public void EventManagerEmptyCrash()
        {
            LoadTextures();
            LoadFonts();

            var shooter = new Mock <Player>().Object;
            var victim  = new Mock <Player>().Object;


            var evtManager = PlayerEventManager.GetInstance();
            var evtData    = new PlayerEventData()
            {
                Shooter = shooter, Victim = victim
            };

            evtManager.Notify(PlayerEventType.KilledPlayer, evtData);

            Assert.True(true);
        }
Beispiel #3
0
        public void EventManagerUnsub()
        {
            LoadTextures();
            LoadFonts();
            var shooter = new Mock <Player>().Object;
            var victim  = new Mock <Player>().Object;

            var scoreboard = new Scoreboard();
            var killnotif  = new KillNotifier();

            var evtManager = PlayerEventManager.GetInstance();

            evtManager.Subscribe(PlayerEventType.PlayerDead, killnotif);
            evtManager.Subscribe(PlayerEventType.KilledPlayer, scoreboard);

            evtManager.Unsubscribe(PlayerEventType.PlayerDead, killnotif);
            evtManager.Unsubscribe(PlayerEventType.KilledPlayer, scoreboard);



            Assert.True(evtManager._listeners[PlayerEventType.PlayerDead].Count == 0 && evtManager._listeners[PlayerEventType.KilledPlayer].Count == 0);
        }