public void GetRoomsByCineIdTest1() { int cineId = 1; List <Room> rooms = roomDAL.GetRoomsByCineId(cineId); query = $"select * from Rooms where cine_id = " + cineId + " order by rand() limit 1;"; Room roomRand = GetRoomExecQuery(query); query = $"select * from Rooms where cine_id = " + cineId + " order by room_id asc limit 1;"; Room roomTop = GetRoomExecQuery(query); query = $"select * from Rooms where cine_id = " + cineId + " order by room_id desc limit 1;"; Room roomBottom = GetRoomExecQuery(query); Assert.NotNull(rooms); Assert.NotNull(roomRand); Assert.NotNull(roomTop); Assert.NotNull(roomBottom); Assert.Contains(roomRand, rooms); Assert.True(rooms.IndexOf(roomTop) == 0); Assert.True(rooms.IndexOf(roomBottom) == (rooms.Count - 1)); }
public List <Room> GetRoomsByCineId(int?cineId) { if (cineId == null) { return(null); } Regex regex = new Regex("[0-9]"); MatchCollection matchCollection = regex.Matches(cineId.ToString()); if (matchCollection.Count < cineId.ToString().Length) { return(null); } return(rdal.GetRoomsByCineId(cineId)); }