Пример #1
0
        public void Admin_Test()
        {
            var serverGuid = Guid.NewGuid();

            var ev = new FakeEventAggregator();

            var logic = new BELogic(ev);

            BECommand command = null;

            logic.ServerUpdateHandler += (s, e) =>
            {
                command = e.Command;
            };


            ev.GetEvent <BEMessageEvent <BEAdminLogMessage> >()
            .Publish(new BEAdminLogMessage(new LogMessage(), serverGuid));


            Assert.IsNotNull(command);
            Assert.AreEqual(CommandType.Admins, command.CommandType);

            GC.KeepAlive(logic);
        }
Пример #2
0
        public void Connect_Test()
        {
            var serverGuid = Guid.NewGuid();

            var ev = new FakeEventAggregator();

            var logic = new BELogic(ev);

            var commands = new List <BECommand>();

            logic.ServerUpdateHandler += (s, e) =>
            {
                commands.Add(e.Command);
            };


            ev.GetEvent <ConnectServerEvent>()
            .Publish(new ServerInfo()
            {
                Id = serverGuid
            });


            Assert.IsNotNull(commands);
            Assert.IsNotNull(commands.FirstOrDefault(x => x.CommandType == CommandType.Bans && x.ServerId == serverGuid));
            Assert.IsNotNull(commands.FirstOrDefault(x => x.CommandType == CommandType.Players && x.ServerId == serverGuid));
            Assert.IsNotNull(commands.FirstOrDefault(x => x.CommandType == CommandType.Admins && x.ServerId == serverGuid));
            Assert.IsNotNull(commands.FirstOrDefault(x => x.CommandType == CommandType.Missions && x.ServerId == serverGuid));

            GC.KeepAlive(logic);
        }
Пример #3
0
        public void Player_Ban_Test()
        {
            var serverGuid = Guid.NewGuid();

            var ev = new FakeEventAggregator();

            var logic = new BELogic(ev);

            var commands = new List <BECommand>();

            logic.ServerUpdateHandler += (s, e) =>
            {
                commands.Add(e.Command);
            };


            ev.GetEvent <BEMessageEvent <BEBanLogMessage> >()
            .Publish(new BEBanLogMessage(new LogMessage(), serverGuid));

            Assert.IsNotNull(commands);
            Assert.IsNotNull(commands.FirstOrDefault(x => x.CommandType == CommandType.Bans && x.ServerId == serverGuid));
            Assert.IsNotNull(commands.FirstOrDefault(x => x.CommandType == CommandType.Players && x.ServerId == serverGuid));

            GC.KeepAlive(logic);
        }