public void AddSystemLogTest_good_id() { int roomid = new Random().Next(); int gameNum = new Random().Next(); int userId = new Random().Next(); int logId = new Random().Next(); Logic.Game.GameRoom toAddg = CreateRoomWithId(gameNum, roomid, userId); proxy.InsertNewGameRoom(toAddg); Database.LinqToSql.SystemLog toAdd = new Database.LinqToSql.SystemLog(); Database.LinqToSql.Log logs = new Database.LinqToSql.Log { LogId = logId, LogPriority = 1 }; toAdd.Log = logs; toAdd.logId = logId; toAdd.msg = "test AddSystemLogTest_good_id()"; toAdd.roomId = roomid; toAdd.game_Id = gameNum; _logDataControler.AddSystemLog(toAdd); Assert.AreEqual(_logsOnlyForTest.GetSystemLogById(logId).logId, logId); _logsOnlyForTest.DeleteSystemLog(logId); _logsOnlyForTest.DeleteLog(logId); Cleanup(gameNum, roomid, userId); }
public void RemoveRoomFromActiveGameListTest_good() { int roomid = new Random().Next(); int gameNum = new Random().Next(); int userId = new Random().Next(); GameRoom toAddg = CreateRoomWithId(gameNum, roomid, userId); toAddg.SetIsActive(true); _gameDataProxy.InsertNewGameRoom(toAddg); IUser user = _userDataProxy.GetUserById(userId); user.AddRoomToActiveGameList(toAddg); Assert.IsTrue(user.RemoveRoomFromActiveGameList(toAddg)); _userDataProxy.DeleteActiveGameOfUser(userId, roomid, gameNum); Cleanup(gameNum, roomid, userId); }
public void AddSysLogTest_good_id_match() { int roomid = new Random().Next(); int gameNum = new Random().Next(); int userId = new Random().Next(); GameRoom toAdd = CreateRoomWithId(gameNum, roomid, userId); proxy.InsertNewGameRoom(toAdd); var systemLog = new SystemLog(roomid, "AddSysLogTest_good_id_match", gameNum); _logDataProxy.AddSysLog(systemLog); var logId = systemLog.LogId; Assert.AreEqual(_logsOnlyForTest.GetSystemLogById(logId).logId, logId); _logsOnlyForTest.DeleteSystemLog(logId); _logsOnlyForTest.DeleteLog(logId); Cleanup(gameNum, roomid, userId); }
//Add new room the games list public bool AddRoom(GameRoom roomToAdd) { lock (padlock) { bool toReturn = false; if (roomToAdd == null) { return(toReturn); } try { // this.games.Add(roomToAdd); toReturn = proxyDB.InsertNewGameRoom(roomToAdd); } catch (Exception e) { ErrorLog log = new ErrorLog("Error while trying to add new room to game center"); logControl.AddErrorLog(log); toReturn = false; } return(toReturn); } }
public void UpdateGameRoomPotSizeTest() { int roomId = new Random().Next(); int gameId = new Random().Next(); int userId1 = 1; int userId2 = 2; int userId3 = 3; GameRoom toAdd = CreateRoomWithId(gameId, roomId, userId1, userId2, userId3); proxy.InsertNewGameRoom(toAdd); bool ans = controller.UpdateGameRoomPotSize(777, roomId); Assert.IsTrue(ans); Cleanup(gameId, roomId, userId1, userId2, userId3); }
public void GetAllActiveGameRoomsTest() { int roomId = new Random().Next(); int gameId = new Random().Next(); int userId1 = new Random().Next(); int room2Id = new Random().Next(); int game2Id = new Random().Next(); int user2Id1 = new Random().Next(); GameRoom toAdd = CreateRoomWithId(gameId, roomId, userId1); GameRoom toAdd2 = CreateRoomWithId(game2Id, room2Id, user2Id1); toAdd.SetIsActive(true); proxy.InsertNewGameRoom(toAdd); proxy.InsertNewGameRoom(toAdd2); proxy.UpdateGameRoom(toAdd); List <IGame> g = proxy.GetAllActiveGameRooms(); bool g1 = false; bool g2 = false; foreach (var game in g) { if (game.Id == roomId) { g1 = true; } else if (game.Id == room2Id) { g2 = true; } } Assert.AreEqual(g1, true); Assert.AreEqual(g2, false); Cleanup(gameId, roomId, userId1); Cleanup(game2Id, room2Id, user2Id1); }