Esempio n. 1
0
        public void PlayRandomGameDraw()
        {
            var gameService = new GameServiceImpl(seed);
            var a           = new User("a", "b")
            {
                Id = 1
            };
            var c = new User("c", "b")
            {
                Id = 2
            };

            gameService.JoinGame(a, GameType.RandomCompetitor);
            gameService.JoinGame(c, GameType.RandomCompetitor);

            var intermediateResult = gameService.Play(a, GameValue.Paper);

            Assert.AreEqual(GameResult.NotCompleted, intermediateResult.Result);
            Assert.AreEqual(null, intermediateResult.Winner);
            Assert.AreEqual(null, intermediateResult.Looser);

            var result = gameService.Play(c, GameValue.Paper);

            Assert.AreEqual(GameResult.Draw, result.Result);
            Assert.AreEqual(a, result.Winner);
            Assert.AreEqual(c, result.Looser);
        }
Esempio n. 2
0
        public void PlaySeveralTimes()
        {
            var gameService = new GameServiceImpl(seed);
            var a           = new User("a", "b")
            {
                Id = 1
            };
            var c = new User("c", "b")
            {
                Id = 2
            };

            gameService.JoinGame(a, GameType.RandomCompetitor);
            gameService.JoinGame(c, GameType.RandomCompetitor);
            for (var i = 0; i < 3; i++)
            {
                var intermediateResult = gameService.Play(a, GameValue.Paper);
                Assert.AreEqual(GameResult.NotCompleted, intermediateResult.Result);
                Assert.AreEqual(null, intermediateResult.Winner);
                Assert.AreEqual(null, intermediateResult.Looser);
                var result = gameService.Play(c, GameValue.Rock);
                Assert.AreEqual(GameResult.HasWinner, result.Result);
                Assert.AreEqual(a, result.Winner);
                Assert.AreEqual(c, result.Looser);
                result.EndGame();
            }
        }
Esempio n. 3
0
        public void PlayRandomGame(GameValue aValue, GameValue cValue, bool aWin)
        {
            var gameService = new GameServiceImpl(seed);
            var a           = new User("a", "b")
            {
                Id = 1
            };
            var c = new User("c", "b")
            {
                Id = 2
            };
            var comp1 = gameService.JoinGame(a, GameType.RandomCompetitor);
            var comp2 = gameService.JoinGame(c, GameType.RandomCompetitor);

            Assert.AreEqual(null, comp1);
            Assert.AreEqual(a, comp2);

            var intermediateResult = gameService.Play(a, aValue);

            Assert.AreEqual(GameResult.NotCompleted, intermediateResult.Result);
            Assert.AreEqual(null, intermediateResult.Winner);
            Assert.AreEqual(null, intermediateResult.Looser);

            var result = gameService.Play(c, cValue);

            Assert.AreEqual(GameResult.HasWinner, result.Result);
            Assert.AreEqual(aWin ? a : c, result.Winner);
            Assert.AreEqual(aWin ? c : a, result.Looser);
        }
Esempio n. 4
0
        public void PlyWithBot()
        {
            var gameService = new GameServiceImpl(seed);
            var a           = new User("a", "b")
            {
                Id = 1
            };

            gameService.JoinGame(a, GameType.Bot);

            var result = gameService.Play(a, GameValue.Paper);

            Assert.AreEqual(GameValue.Rock, result.Looser.Value);
            Assert.AreEqual(GameResult.HasWinner, result.Result);
            Assert.AreEqual(a, result.Winner);
        }