public void GenerateBingoCard_FreeCenter_Succeeds()
        {
            var input = new BingoCardCreationModel()
            {
                Name = "Pearl Jam",
                IsCenterSquareFree = true,
                Size = 3,
            };

            var actual = _bingoCardLogic.GenerateBingoCard(input);

            Assert.Equal(input.Name, actual.Name);
            Assert.Equal(input.Size, actual.Grid.Length);
            Assert.Equal(9, GetNumberOfCells(actual.Grid));
            Assert.Equal(4, GetCenterFreeIndex(actual.Grid));
        }
Exemple #2
0
        public BingoGameModel CreateNewGame(BingoGameCreationModel gameCreationModel)
        {
            if (gameCreationModel == null || string.IsNullOrWhiteSpace(gameCreationModel.Name) || gameCreationModel.Players.Count() <= 0 || gameCreationModel.Size <= 0)
            {
                throw new ArgumentException("No name for the game provided or invalid number of players or grid size");
            }

            foreach (var player in gameCreationModel.Players)
            {
                player.BingoCard = _bingoCardLogic.GenerateBingoCard(new BingoCardCreationModel()
                {
                    Name = player.Name,
                    IsCenterSquareFree = true,
                    Size = gameCreationModel.Size
                });
            }

            return(new BingoGameModel()
            {
                DrawnNumber = _bingoNumberLogic.GetNextNumber(),
                Players = gameCreationModel.Players
            });
        }