Beispiel #1
0
        public void StoreMatch_DoesNotThrowException()
        {
            var match = new MatchState
            {
                id             = Guid.NewGuid(),
                gameStartTime  = DateTime.Now,
                gameEndTime    = DateTime.Now.AddHours(1),
                gameType       = GameType.TicTacToe,
                operationState = GameOperationState.Completed,
                winnerId       = _firstPlayer,
                playerTurnId   = _firstPlayer,
                players        = new List <Guid> {
                    _firstPlayer, _secondPlayer
                },
                inGameState = new TicTacToeState
                {
                    firstPlayer  = _firstPlayer,
                    secondPlayer = _secondPlayer,
                    board        = new List <PlayerMark>(),
                }
            };

            _controller.StoreMatch(match);

            using (var context = new GameServerEntities())
            {
                var storedMatches = context.Matches.ToList();
                Assert.Contains(match.id, storedMatches.Select(x => x.id));
            }
        }
Beispiel #2
0
        public void CreatePlayer_DoesNotThrowException()
        {
            var playerId = Guid.NewGuid();
            var username = playerId.ToString();
            var password = "******";

            _controller.CreatePlayer(playerId, username, password);

            using (var context = new GameServerEntities())
            {
                var players = context.Players.Select(x => x.username);
                Assert.Contains(username, players);
            }
        }