コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }