Exemplo n.º 1
0
        public void InsertTest()
        {
            //Arrange
            gameTableDB = new GameTableDB();
            bool found = false;
            var  table = new GameTableModel("TestTable");

            table.DeckId = 2;
            //Act
            gameTableDB.Insert(table);
            List <GameTableModel> gameTables = gameTableDB.GetAll().ToList();

            for (int i = 0; i < gameTables.Count && !found; i++)
            {
                if (gameTables[i].TableName == table.TableName)
                {
                    table.Id = gameTables[i].Id;
                }
            }
            var tableT = gameTableDB.GetById(table.Id);

            //Assert
            Assert.AreEqual(table.TableName, tableT.TableName);
            //Cleanup
            gameTableDB.Delete(table);
        }
Exemplo n.º 2
0
        public void CreateGameTableTest()
        {
            // arrange
            gameTableManagement = new GameTableManagement();
            IGameTableDBIF tableDB = new GameTableDB();
            var            user1   = new CGUser();

            //Act
            var table      = gameTableManagement.CreateGameTable(user1, "GameTable");
            var tableModel = tableDB.GetGameTableByTableName("GameTable");

            //Assert
            Assert.AreEqual(tableModel.TableName, "GameTable");

            //Cleanup
            tableDB.Delete(tableModel);
        }
Exemplo n.º 3
0
        public void DeleteTest()
        {
            gameTableDB = new GameTableDB();
            List <GameTableModel> gameTables = gameTableDB.GetAll().ToList();
            bool           found             = false;
            GameTableModel table             = new GameTableModel {
                DeckId    = 2,
                TableName = "TestTable"
            };

            for (int i = 0; i < gameTables.Count && !found; i++)
            {
                if (gameTables[i].TableName == table.TableName)
                {
                    table.Id = gameTables[i].Id;
                }
            }
            var table1 = gameTableDB.GetById(table.Id);

            gameTableDB.Delete(table);
            table = gameTableDB.GetById(table.Id);
            Assert.IsNull(table);
        }
        public void GetUserByTableIdTest()
        {
            //Arrange
            cgUserDB = new CGUserDB();
            GameTableDB gameTableDB = new GameTableDB();
            var         table       = new GameTableModel("TestTable");

            table.DeckId = 2;
            table.seats  = 4;
            //Act
            gameTableDB.Insert(table);
            table = gameTableDB.GetGameTableByTableName("TestTable");
            GameTable gameTable = GameTableConverter.ConvertFromGameTableModelToGameTable(table);

            gameTable.Users.Add(CGUserConverter.convertFromCGUserModelToCGUser(cgUserDB.GetById("Test")));
            CGUserModel testUser = cgUserDB.GetById("Test");

            cgUserDB.UpdateUserTableId(testUser, table.Id);
            List <CGUserModel> foundUser = cgUserDB.GetUserByTableId(table.Id);

            Assert.AreEqual(testUser.UserName, foundUser[0].UserName);
            gameTableDB.Delete(table);
        }
        public void StartGameTest()
        {
            //Arrange
            GameController   gameController = new GameController();
            IGameDBIF        gameDB         = new GameDB();
            IDeckDBIF        deckDb         = new DeckDB();
            ICGUserDBIF      userDB         = new CGUserDB();
            IGameTableDBIF   gameTableDB    = new GameTableDB();
            List <GameModel> games          = (List <GameModel>)gameDB.GetAll();
            List <CGUser>    users          = CGUserConverter.ConvertFromListOfCGUserModelToListOfCGUser((List <CGUserModel>)userDB.GetAll());
            GameTable        gameTable      = new GameTable {
                Deck      = DeckConverter.ConvertFromDeckModelToDeck(deckDb.GetById(2)),
                seats     = 4,
                TableName = "TestTable",
            };

            if (users.Count > 4)
            {
                for (int i = 0; i < 4; i++)
                {
                    gameTable.Users.Add(users[i]);
                }
            }
            gameTableDB.Insert(GameTableConverter.ConvertFromGameTableToGameTableModel(gameTable));
            gameTable = GameTableConverter.ConvertFromGameTableModelToGameTable(gameTableDB.GetGameTableByTableName("TestTable"));

            //Act
            gameController.StartGame(gameTable);
            List <GameModel> games2 = (List <GameModel>)gameDB.GetAll();

            //Assert
            Assert.AreNotEqual(games.Count, games2.Count);
            //Cleanup
            gameDB.Delete(gameDB.GetByTableId(gameTable.Id));
            gameTableDB.Delete(GameTableConverter.ConvertFromGameTableToGameTableModel(gameTable));
        }