public void TestInsufficentWordsResultsInEmptyEvent() {
            var called = false;

            var protocol = new SecondGame();

            protocol.ProtocolEvent += (protocol1, args) => { called = true; };

            var request = new FrostbitePacket();

            var response = new FrostbitePacket();

            protocol.PlayerOnKillDispatchHandler(request, response);

            Assert.IsFalse(called);
        }
        public void TestBanlistWithIpBanPassedAndIgnored() {
            var protocol = new SecondGame();

            var request = new FrostbitePacket() {
                Packet = new Packet() {
                    Words = new List<String>() {
                        "banList.list"
                    }
                }
            };

            var response = new FrostbitePacket() {
                Packet = new Packet() {
                    Words = new List<String>() {
                        "OK",
                        "name",
                        "Phil_k",
                        "perm",
                        "0",
                        "0",
                        "Geoff",
                        "ip",
                        "127.0.0.1",
                        "perm",
                        "0",
                        "0",
                        "Geoff",
                        "guid",
                        "EA_12345678901234567890123456789012",
                        "perm",
                        "0",
                        "0",
                        "Geoff"
                    }
                }
            };

            protocol.BanListListDispatchHandler(request, response);

            Assert.AreEqual(2, protocol.State.Bans.Count);
        }
        public void TestPassingThroughCorrectFormatResultsInEvent() {
            var called = false;
            var protocol = new SecondGame();

            protocol.State.Players.TryAdd("EA_1", new PlayerModel() {
                Name = "Phogue",
                Uid = "EA_1",
                Score = 100,
                Kills = 5,
                Deaths = 5
            });

            protocol.State.Players.TryAdd("EA_2", new PlayerModel() {
                Name = "Zaeed",
                Uid = "EA_2",
                Score = 100,
                Kills = 5,
                Deaths = 5
            });

            protocol.ProtocolEvent += (protocol1, args) => { called = true; };

            var request = new FrostbitePacket() {
                Packet = new Packet() {
                    Words = new List<String>() {
                        "player.onKill",
                        "Phogue",
                        "Zaeed",
                        "Fairyfloss",
                        "true"
                    }
                }
            };

            var response = new FrostbitePacket();

            protocol.PlayerOnKillDispatchHandler(request, response);

            Assert.IsTrue(called);
        }
        public void TestWords4NotABooleanResultsInEmptyEvent() {
            var called = false;
            var protocol = new SecondGame();

            protocol.ProtocolEvent += (protocol1, args) => { called = true; };

            var request = new FrostbitePacket() {
                Packet = new Packet() {
                    Words = new List<String>() {
                        "a",
                        "b",
                        "c",
                        "d",
                        "e"
                    }
                }
            };

            var response = new FrostbitePacket();

            protocol.PlayerOnKillDispatchHandler(request, response);

            Assert.IsFalse(called);
        }
        public void TestHeadshotFalseYieldsCorrectFlags() {
            var protocol = new SecondGame();

            protocol.ProtocolEvent += (protocol1, args) => Assert.AreEqual(FrostbiteGame.Bodyshot, args.Now.Kills.First().Scope.HumanHitLocations.First());

            var request = new FrostbitePacket() {
                Packet = new Packet() {
                    Words = new List<String>() {
                        "player.onKill",
                        "Phogue",
                        "Zaeed",
                        "Fairyfloss",
                        "false"
                    }
                }
            };

            var response = new FrostbitePacket();

            protocol.PlayerOnKillDispatchHandler(request, response);
        }
        public void TestAKnownVictimWillHaveTheirDeathsIncremented() {
            var called = false;
            var protocol = new SecondGame();

            protocol.State.Players.TryAdd("EA_1", new PlayerModel() {
                Name = "Phogue",
                Uid = "EA_1",
                Score = 100,
                Kills = 5,
                Deaths = 5
            });

            protocol.State.Players.TryAdd("EA_2", new PlayerModel() {
                Name = "Zaeed",
                Uid = "EA_2",
                Score = 100,
                Kills = 5,
                Deaths = 5
            });

            protocol.ProtocolEvent += (protocol1, args) => {
                called = true;

                Assert.AreEqual("EA_2", args.Now.Kills.First().Scope.Players.First().Uid);
                Assert.AreEqual(6, args.Now.Kills.First().Scope.Players.First().Deaths);
            };

            var request = new FrostbitePacket() {
                Packet = new Packet() {
                    Words = new List<String>() {
                        "player.onKill",
                        "Phogue",
                        "Zaeed",
                        "fairyfloss",
                        "true"
                    }
                }
            };

            var response = new FrostbitePacket();

            protocol.PlayerOnKillDispatchHandler(request, response);

            Assert.IsTrue(called);
        }
        public void TestAnUnknownItemResultsInThatItemInTheKillerInventory() {
            var called = false;
            var protocol = new SecondGame();

            protocol.State.Players.TryAdd("EA_1", new PlayerModel() {
                Name = "Phogue",
                Uid = "EA_1",
                Score = 100,
                Kills = 5,
                Deaths = 5
            });

            protocol.State.Players.TryAdd("EA_2", new PlayerModel() {
                Name = "Zaeed",
                Uid = "EA_2",
                Score = 100,
                Kills = 5,
                Deaths = 5
            });

            protocol.ProtocolEvent += (protocol1, args) => {
                called = true;

                Assert.AreEqual("fairyfloss", args.Now.Kills.First().Now.Players.First().Inventory.Now.Items.First().Name);
                Assert.IsEmpty(args.Now.Kills.First().Now.Players.First().Inventory.Now.Items.First().FriendlyName);
            };

            var request = new FrostbitePacket() {
                Packet = new Packet() {
                    Words = new List<String>() {
                        "player.onKill",
                        "Phogue",
                        "Zaeed",
                        "fairyfloss",
                        "true"
                    }
                }
            };

            var response = new FrostbitePacket();

            protocol.PlayerOnKillDispatchHandler(request, response);

            Assert.IsTrue(called);
        }