public void FrontRowCheckPassTest() { var room = new Room() { Layout = new RoomLayout() { BackX = 0, BackY = 0, FrontX = 3, FrontY = 3, LayoutID = 888 } }; List <Seat> occupiedSeats = new List <Seat>() { }; var ass = new AutomaticSeatSelection(); List <SeatCoord> ret = ass.CalculateSeats(room, 3, occupiedSeats); List <SeatCoord> expected = new List <SeatCoord>() { new SeatCoord(1, 0), new SeatCoord(1, 1), new SeatCoord(1, 2) }; Assert.IsTrue(AreCoordListsEqual(ret, expected)); }
public void BackRowPlusFrontRowPlusFiveSeatsCheckFailTest() { var room = new Room() { Layout = new RoomLayout() { BackX = 5, BackY = 6, FrontX = 10, FrontY = 4, LayoutID = 888 } }; List <Seat> occupiedSeats = new List <Seat>() { }; var ass = new AutomaticSeatSelection(); List <SeatCoord> ret = ass.CalculateSeats(room, 5, occupiedSeats); List <SeatCoord> expected = new List <SeatCoord>() { new SeatCoord(7, 0), new SeatCoord(7, 1), new SeatCoord(7, 2), // ONLY 3 out of 5 expected Coords so we can test FAIL }; Assert.IsFalse(AreCoordListsEqual(ret, expected)); }
public void BackRowCheckFailTest() { var room = new Room() { Layout = new RoomLayout() { BackX = 5, BackY = 6, FrontX = 0, FrontY = 0, LayoutID = 888 } }; List <Seat> occupiedSeats = new List <Seat>() { }; var ass = new AutomaticSeatSelection(); List <SeatCoord> ret = ass.CalculateSeats(room, 3, occupiedSeats); List <SeatCoord> expected = new List <SeatCoord>() { new SeatCoord(3, 2), new SeatCoord(3, 3), new SeatCoord(0, 0) // THIS COORD IS INCORRECT SO WE CAN TEST }; Assert.IsFalse(AreCoordListsEqual(ret, expected)); }
// GET: Summary public ActionResult SummaryView() { CinemaViewModel model = (CinemaViewModel)TempData["model"]; if (model.GetAllTicketsQuantity() <= 0) { TempData["model"] = model; return(RedirectToAction("RateOverview", "Rate")); } if (model.TotalFreeSeats() < model.GetAllTicketsQuantity()) { ViewBag.seatError = "U heeft meer tickets besteld dan dat er stoelen zijn."; TempData["model"] = model; return(RedirectToAction("RateOverview", "Rate")); } ViewBag.Base64 = @"data:image/gif;base64," + Convert.ToBase64String(model.SelectedFilm.Image); var context = new EFDbContext(); var ass = new AutomaticSeatSelection(); var occupiedSeats = new List <Seat>(); foreach (Seat s in context.Seats.ToList()) { Ticket t = context.Tickets.ToList().Find(ti => ti.SeatID == s.SeatID && ti.ShowingID == model.SelectedShowing.ShowingID); if (t == null) { continue; } if (s.SeatID != t.SeatID) { continue; } occupiedSeats.Add(s); } if (model.SeatCoordList.Count == 0) { model.SeatCoordList = ass.CalculateSeats(model.SelectedShowing.Room, model.GetAllTicketsQuantity(), occupiedSeats); } model.SeatSelectionGUI = ass.VisualizeSeats(model.SelectedShowing.Room, occupiedSeats, model.SeatCoordList); TempData["model"] = model; return(View("SummaryView", model)); }
public void BackRowPlusFrontRowPlusOccupiedFirstCheckedRowCheckFailTest() { var room = new Room() { Layout = new RoomLayout() { BackX = 5, BackY = 6, FrontX = 10, FrontY = 4, LayoutID = 888 } }; List <Seat> occupiedSeats = new List <Seat>() { new Seat() { RowX = 1, RowY = 7 }, new Seat() { RowX = 2, RowY = 7 }, new Seat() { RowX = 3, RowY = 7 }, }; var ass = new AutomaticSeatSelection(); List <SeatCoord> ret = ass.CalculateSeats(room, 3, occupiedSeats); List <SeatCoord> expected = new List <SeatCoord>() { new SeatCoord(8, 2), new SeatCoord(8, 3), new SeatCoord(8, 1) // THIS COORD IS INCORRECT SO WE CAN TEST }; Assert.IsFalse(AreCoordListsEqual(ret, expected)); }