Esempio 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);
        }
Esempio n. 2
0
        public static Game ConvertFromGameModelToGame(GameModel gameModel)
        {
            IGameTableDBIF gameTableDB    = new GameTableDB();
            GameTableModel gameTableModel = gameTableDB.GetById(gameModel.GameTableId);
            Game           game           = new Game()
            {
                Id        = gameModel.Id,
                gameTable = GameTableConverter.ConvertFromGameTableModelToGameTable(gameTableModel)
            };

            return(game);
        }
Esempio n. 3
0
        public void GetbyIdTest()
        {
            gameTableDB = new GameTableDB();
            GameTableModel        table = null, table2 = null;
            List <GameTableModel> gameTables = gameTableDB.GetAll().ToList();

            if (gameTables.Count > 0)
            {
                table = gameTables[0];
            }
            table2 = gameTableDB.GetById(table.Id);
            Assert.AreEqual(table2.Id, table.Id);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public void DeleteGameTableTest()
        {
            // arrange
            gameTableManagement = new GameTableManagement();
            IGameTableDBIF tableDB = new GameTableDB();
            ICGUserDBIF    userDB  = new CGUserDB();
            CGUser         user    = CGUserConverter.convertFromCGUserModelToCGUser(userDB.GetById("Test"));

            gameTableManagement.CreateGameTable(user, "TestTable");
            GameTable table = gameTableManagement.GetGameTableByTableName("TestTable");

            //Act
            gameTableManagement.DeleteGameTable(table.Id);

            //Assert
            Assert.IsNull(tableDB.GetById(table.Id));
        }