Example #1
0
        public async Task GetTeamIdOfPlayerAfterRemoval()
        {
            ByCommandTeamManager teamManager = new ByCommandTeamManager();

            Assert.IsTrue(teamManager.TryAddTeam(FirstTeam, out _), "Couldn't add the team");
            Assert.IsTrue(
                teamManager.TryAddPlayerToTeam(FirstPlayerId, FirstPlayerName, FirstTeam), "Couldn't add the player");
            Assert.IsTrue(
                teamManager.TryRemovePlayerFromTeam(FirstPlayerId), "Couldn't remove the player");
            Assert.IsNull(await teamManager.GetTeamIdOrNull(FirstPlayerId), "Unexpected team ID");
        }
Example #2
0
        public async Task RemovePlayerFromTeam()
        {
            ByCommandTeamManager teamManager = new ByCommandTeamManager();

            Assert.IsTrue(teamManager.TryAddTeam(FirstTeam, out _), "Couldn't add team");

            Assert.IsTrue(
                teamManager.TryAddPlayerToTeam(FirstPlayerId, FirstPlayerName, FirstTeam),
                "Couldn't add player to team");
            Assert.IsTrue(teamManager.TryRemovePlayerFromTeam(FirstPlayerId), "Couldn't remove player from team");

            IEnumerable <PlayerTeamPair> pairs = await teamManager.GetKnownPlayers();

            Assert.IsFalse(pairs.Any(), "There should be no players, but some were found");
        }
Example #3
0
        public async Task CannotRemoveNonexistentPlayerFromTeam()
        {
            ByCommandTeamManager teamManager = new ByCommandTeamManager();

            Assert.IsTrue(teamManager.TryAddTeam(FirstTeam, out _), "Couldn't add team");

            Assert.IsTrue(
                teamManager.TryAddPlayerToTeam(FirstPlayerId, FirstPlayerName, FirstTeam),
                "Couldn't add player to team");
            Assert.IsFalse(teamManager.TryRemovePlayerFromTeam(SecondPlayerId), "Second player shouldn't be removable");

            IEnumerable <PlayerTeamPair> pairs = await teamManager.GetKnownPlayers();

            Assert.AreEqual(1, pairs.Count(), "Unexpected number of players");
            PlayerTeamPair pair = pairs.First();

            Assert.AreEqual(FirstPlayerId, pair.PlayerId, "Player should be known");
            Assert.AreEqual(FirstTeam, pair.TeamId, "Player should be on the first team");
            Assert.AreEqual(FirstPlayerName, pair.PlayerDisplayName, "Player should have a name");
        }