Exemple #1
0
        public void AddPlayerToSingleTeam()
        {
            ITeam         team         = Mock.Of <ITeam>();
            IPlayer       player       = Mock.Of <IPlayer>();
            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { team });

            TeamAssigner.AddPlayer(player);

            Mock.Get(team).Verify(t => t.AddPlayer(player));
        }
Exemple #2
0
        public void RemovePlayerFromNullTeam()
        {
            ITeam   team   = Mock.Of <ITeam>();
            IPlayer player = Mock.Of <IPlayer>();

            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { team });

            TeamAssigner.RemovePlayer(player);

            Mock.Get(team).Verify(t => t.RemovePlayer(player), Times.Never());
        }
Exemple #3
0
        public void RemovePlayerFromTeam()
        {
            ITeam   team   = Mock.Of <ITeam>();
            IPlayer player = Mock.Of <IPlayer>(p => p.Team == team);

            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { team });

            TeamAssigner.RemovePlayer(player);

            Mock.Get(team).Verify(t => t.RemovePlayer(player));
        }
Exemple #4
0
        public void RemovePlayerFromUnexistingTeam()
        {
            ITeam   team1  = Mock.Of <ITeam>();
            ITeam   team2  = Mock.Of <ITeam>();
            IPlayer player = Mock.Of <IPlayer>(p => p.Team == team1);

            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { team2 });

            TeamAssigner.RemovePlayer(player);

            Mock.Get(team1).Verify(t => t.RemovePlayer(player), Times.Never());
        }
Exemple #5
0
        public void AddPlayerToUnequalProgressTeams()
        {
            IPlayer player = Mock.Of <IPlayer>();
            ITeam   team1  = Mock.Of <ITeam>(t => t.Progress == 0.5f);
            ITeam   team2  = Mock.Of <ITeam>(t => t.Progress == 0.4f);
            ITeam   team3  = Mock.Of <ITeam>(t => t.Progress == 0.3f);

            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { team1, team2, team3 });

            TeamAssigner.AddPlayer(player);

            Mock.Get(team1).Verify(t => t.AddPlayer(player), Times.Never());
            Mock.Get(team2).Verify(t => t.AddPlayer(player), Times.Never());
            Mock.Get(team3).Verify(t => t.AddPlayer(player));
        }
Exemple #6
0
        public void AddPlayerToUnequalSizedTeams()
        {
            IPlayer player = Mock.Of <IPlayer>();
            ITeam   team1  = Mock.Of <ITeam>(t => t.Size == 4);
            ITeam   team2  = Mock.Of <ITeam>(t => t.Size == 3);
            ITeam   team3  = Mock.Of <ITeam>(t => t.Size == 5);

            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { team1, team2, team3 });

            TeamAssigner.AddPlayer(player);

            Mock.Get(team1).Verify(t => t.AddPlayer(player), Times.Never());
            Mock.Get(team2).Verify(t => t.AddPlayer(player));
            Mock.Get(team3).Verify(t => t.AddPlayer(player), Times.Never());
        }
Exemple #7
0
        public void AddPlayerToEqualTeams()
        {
            int count = 0;

            IPlayer player = Mock.Of <IPlayer>();

            Mock <ITeam> team1Mock = new Mock <ITeam>();

            team1Mock.SetupGet(t => t.Size).Returns(3);
            team1Mock.SetupGet(t => t.Progress).Returns(0.5f);
            team1Mock.Setup(t => t.AddPlayer(player)).Callback(() => count++);

            Mock <ITeam> team2Mock = new Mock <ITeam>();

            team2Mock.SetupGet(t => t.Size).Returns(3);
            team2Mock.SetupGet(t => t.Progress).Returns(0.5f);
            team2Mock.Setup(t => t.AddPlayer(player)).Callback(() => count++);

            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { team1Mock.Object, team2Mock.Object });

            TeamAssigner.AddPlayer(player);

            Assert.AreEqual(1, count);
        }
Exemple #8
0
        public void TestMultipleTeams()
        {
            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { Mock.Of <ITeam>(), Mock.Of <ITeam>(), Mock.Of <ITeam>() });

            Assert.AreEqual(3, TeamAssigner.NumberOfTeams);
        }
Exemple #9
0
        public void TestSingleTeam()
        {
            ITeamAssigner TeamAssigner = new TeamAssigner(new[] { Mock.Of <ITeam>() });

            Assert.AreEqual(1, TeamAssigner.NumberOfTeams);
        }