Exemplo n.º 1
0
        public int GetsCorrectVictor(Pick p1, Pick p2)
        {
            List<IPlayer> players = new List<IPlayer>();
            IPlayer player1 = Substitute.For<IPlayer>();
            player1.Pick.Returns(p1);
            player1.Slot.Returns(1);
            players.Add(player1);
            IPlayer player2 = Substitute.For<IPlayer>();
            player2.Pick.Returns(p2);
            player2.Slot.Returns(2);

            players.Add(player2);

            var game = new Game(players);

            var gameResult = Result.None;
            var victor = -1;

            game.GameEnds = (result, i) =>
            {
                gameResult = result;
                victor = i;
            };

            game.StartGame();
            Thread.Sleep(100);
            Assert.AreEqual(Result.Victory, gameResult);

            return victor;
        }
Exemplo n.º 2
0
 public void CallsAllDelegates()
 {
     var game = new Game(null);
     bool cd1 = false;
     bool cd2 = false;
     bool cd3 = false;
     game.CountDownTickOne = () => cd1 = true;
     game.CountDownTickTwo = () => cd2 = true;
     game.CountDownTickGo = () => cd3 = true;
     game.StartGame();
     Thread.Sleep(100);
     Assert.AreEqual(true, cd1);
     Assert.AreEqual(true, cd2);
     Assert.AreEqual(true, cd3);
 }