Beispiel #1
0
        public void MatchTeamAmbiguous()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            Team t1 = CreateTeam("Team 17");

            t1.AddClanTag("x", Builtins.ManualSource, TagOption.Front);

            Team t2 = CreateTeam("Example 18");

            t2.AddClanTag("e", Builtins.ManualSource, TagOption.Front);

            database.expectedTeams = new List <Team> {
                t1, t2
            };
            controller.Initialise();

            // Match 'e' which will match the  'e' for a tag and 'e' in team
            Team[] matched = controller.MatchTeam("e");
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 2);

            // Assert that the returned order is t2 then t1.
            Assert.IsTrue(matched[0] == t2);
            Assert.IsTrue(matched[1] == t1);
        }
Beispiel #2
0
        public void MatchTeamByRegex_InvalidRegex()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Team t1 = CreateTeam("Inkology");

            t1.AddClanTag("¡g", Builtins.ManualSource, TagOption.Front);

            Team t2 = CreateTeam("Inkfected");

            t2.AddClanTag("τイ", Builtins.ManualSource, TagOption.Front);

            database.expectedTeams = new List <Team> {
                t1, t2
            };

            controller.LoadDatabase();
            Team[] matched = controller.MatchTeam("[", new MatchOptions {
                IgnoreCase = true, QueryIsRegex = true
            });
            Assert.IsNotNull(matched);
            Assert.AreEqual(0, matched.Length);
        }
Beispiel #3
0
        public void BuildControllerTest()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();
            Assert.IsTrue(database.loadCalled);
        }
Beispiel #4
0
        public void LoadDatabaseTest()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();
            Assert.IsTrue(database.loadCalled);

            database.loadCalled = false;
            Team exampleTeam = new Team("Example Team", Builtins.ManualSource);

            exampleTeam.AddClanTag("e.g", Builtins.ManualSource, TagOption.Front);
            exampleTeam.AddDivision(new Division(1, DivType.DSB), Builtins.ManualSource);
            var TEAM_ID = exampleTeam.Id;

            database.expectedTeams = new List <Team> {
                exampleTeam
            };
            var PLAYER_NAME = "Example Name";

            database.expectedPlayers = new List <Player>
            {
                new Player(PLAYER_NAME, new Guid[] { TEAM_ID }, Builtins.ManualSource)
            };
            var PLAYER_ID = database.expectedPlayers[0].Id;

            controller.LoadDatabase();
            Assert.IsTrue(database.loadCalled);

            // Also check the player and team is now in the controller
            var players = controller.MatchPlayer(PLAYER_ID.ToString(), new MatchOptions {
                FilterOptions = FilterOptions.SlappId
            });

            Assert.IsNotNull(players.FirstOrDefault());
            var player = players[0];

            Assert.IsTrue(player.Name.Value == PLAYER_NAME);

            var teams = controller.MatchTeam(TEAM_ID.ToString(), new MatchOptions {
                FilterOptions = FilterOptions.SlappId
            });

            Assert.IsNotNull(teams.FirstOrDefault());
            var team = teams[0];

            Assert.IsTrue(team.CurrentDiv.Value == 1);
            Assert.IsTrue(team.CurrentDiv.DivType == DivType.DSB);

            // Verify getting the players for that team returns our player
            var playersForExampleTeam = controller.GetPlayersForTeam(exampleTeam);

            Assert.IsNotNull(playersForExampleTeam);
            Assert.IsTrue(playersForExampleTeam.Count == 1);
            Assert.IsTrue(playersForExampleTeam[0].player.Equals(player));
        }
Beispiel #5
0
        public void MatchTeamNoMatchTest()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Team[] matched = controller.MatchTeam("WO");
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 0);
        }
Beispiel #6
0
        public void MatchPlayerNoMatchTest()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Player[] matched = controller.MatchPlayer("example");
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 0);
        }
Beispiel #7
0
        public void MatchPlayerByNameTest()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Player p1 = CreatePlayer("Player 17"); // Purposefully mixed case

            database.expectedPlayers = new List <Player> {
                p1
            };

            controller.LoadDatabase();
            Player[] matched = controller.MatchPlayer("player"); // Purposefully mixed case
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 1);
        }
Beispiel #8
0
        public void MatchPlayerByTagTest_NearMatched()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Player p1 = CreatePlayer("BΛÐ SΛVΛGΞ");

            database.expectedPlayers = new List <Player> {
                p1
            };

            controller.LoadDatabase();
            Player[] matched = controller.MatchPlayer("bad savage");
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 1);
        }
Beispiel #9
0
        public void MatchTeamByNameTest()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Team t = CreateTeam("Team 17");                             // Purposefully mixed case

            t.AddClanTag("WO", Builtins.ManualSource, TagOption.Front); // Purposefully upper-case
            database.expectedTeams = new List <Team> {
                t
            };

            controller.LoadDatabase();
            Team[] matched = controller.MatchTeam("team"); // Purposefully mixed case
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 1);
        }
Beispiel #10
0
        public void MatchTeamByTagTest_NearMatched()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Team t = CreateTeam("Inkology");

            t.AddClanTag("¡g", Builtins.ManualSource, TagOption.Front);
            database.expectedTeams = new List <Team> {
                t
            };

            controller.LoadDatabase();
            Team[] matched = controller.MatchTeam("ig"); // Note i != ¡
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 1);
        }
Beispiel #11
0
        public void MatchPlayersAmbiguous()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Player p1 = CreatePlayer("Player 17");
            Player p2 = CreatePlayer("Player 18");

            database.expectedPlayers = new List <Player> {
                p1, p2
            };

            controller.LoadDatabase();
            Player[] matched = controller.MatchPlayer("lay");
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 2);
        }
Beispiel #12
0
        public void MatchPlayerByTagTest_ExactMatched()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Player p1 = CreatePlayer("BΛÐ SΛVΛGΞ");

            database.expectedPlayers = new List <Player> {
                p1
            };

            controller.LoadDatabase();
            Player[] matched = controller.MatchPlayer("BΛÐ SΛVΛGΞ", new MatchOptions {
                IgnoreCase = false, NearCharacterRecognition = false
            });
            Assert.IsNotNull(matched);
            Assert.IsTrue(matched.Length == 1);
        }
Beispiel #13
0
        public void MatchPlayerByRegex_InvalidRegex()
        {
            UnitTestDatabase   database   = new UnitTestDatabase();
            SplatTagController controller = new SplatTagController(database);

            controller.Initialise();

            Player p1 = CreatePlayer("¡g Slate");
            Player p2 = CreatePlayer("Slate*NBF");

            database.expectedPlayers = new List <Player> {
                p1, p2
            };

            controller.LoadDatabase();
            Player[] matched = controller.MatchPlayer("[", new MatchOptions {
                IgnoreCase = true, QueryIsRegex = true
            });
            Assert.IsNotNull(matched);
            Assert.AreEqual(0, matched.Length);
        }