public void CanFit_CourseWillFitOnlyInLastDay_Yes() { course2.Students = 20; room2.Seats = 20; broom3 = new BookableRoom(end.AddMinutes(2), end.AddMinutes(7), room2); broomList2 = new List<BookableRoom>() { broom3 }; day2 = new Day(broomList2); table1 = new Timetable(new List<Day>() { day1, day2 }); Assert.IsTrue(table1.CanFit(course2)); }
public void Clone_DeepCopy() { Day clone = (Day)day1.Clone(); BookableRoom broom3 = new BookableRoom(start.AddMinutes(5), start.AddMinutes(10), new Room()); // Mutate Assert.IsTrue(clone.Fit(course1)); Assert.IsTrue(clone.IsCourseBooked(course1)); Assert.IsFalse(day1.IsCourseBooked(course1)); clone.Number = 1; Assert.AreEqual(0, day1.Number); Assert.AreEqual(1, clone.Number); clone.Rooms.Add(broom3); Assert.IsTrue(clone.Rooms.Contains(broom3)); Assert.IsFalse(day1.Rooms.Contains(broom3)); }
public Timetable generateDefaultTimeTable() { // Resources Resource resource1 = new Resource("Projector"); List<Resource> resources = new List<Resource>() { resource1 }; // Rooms Room room1 = new Room("001", 30, resources); Room room2 = new Room("112", 30, null); Room room3 = new Room("110", 35, resources); // Set Room avalability BookableRoom book1 = new BookableRoom(Extensions.DateTimeCreator(0, 8, 30), Extensions.DateTimeCreator(0, 16, 0), room1); BookableRoom book2 = new BookableRoom(Extensions.DateTimeCreator(0, 8, 30), Extensions.DateTimeCreator(0, 16, 0), room2); BookableRoom book3 = new BookableRoom(Extensions.DateTimeCreator(0, 8, 30), Extensions.DateTimeCreator(0, 16, 0), room3); List<BookableRoom> rooms1 = new List<BookableRoom>() { (BookableRoom)book1.Clone(), (BookableRoom)book2.Clone() }; List<BookableRoom> rooms2 = new List<BookableRoom>() { (BookableRoom)book2.Clone(), (BookableRoom)book3.Clone() }; List<BookableRoom> rooms3 = new List<BookableRoom>() { (BookableRoom)book1.Clone(), (BookableRoom)book3.Clone() }; // Days Day day1 = new Day(1, rooms1); Day day2 = new Day(2, rooms2); Day day3 = new Day(3, rooms3); // Timetable Timetable timetable = new Timetable(new List<Day>() { day1, day2, day3 }); return timetable; }
public void init() { resource1 = new Resource("TV"); resource2 = new Resource("Projector"); resource3 = new Resource("PC"); resources1 = new List<Resource>() { resource1, resource2 }; resources2 = new List<Resource>() { resource1, resource3 }; room = new Room(10, resources1); start = DateTime.Now; end = start.AddMinutes(30); broom1 = new BookableRoom(start, end, room); broom2 = new BookableRoom(start.AddMinutes(1), start.AddMinutes(41), new Room(20, resources2)); course1 = new Course(30, 10, resources1); course2 = new Course(40, 20, resources2); broomList1 = new List<BookableRoom>() { broom1, broom2 }; broomList2 = new List<BookableRoom>() { (BookableRoom)broom1.Clone(), (BookableRoom)broom2.Clone() }; day1 = new Day(broomList1); day2 = new Day(broomList2); }
public void Fit_ToFull_Yes() { end = start.AddMinutes(5); broom1 = new BookableRoom(start, end, room); broom2 = new BookableRoom(end.AddMinutes(60), end.AddMinutes(65), new Room(10, resources2)); course1.Duration = 1; course2.Duration = 1; course1.Students = 1; course2.Students = 1; day1 = new Day(new List<BookableRoom>() { broom1, broom2 }); for (int i = 0; i < 5; i++) { Assert.IsTrue(day1.Fit(course1)); } Assert.IsFalse(day1.Fit(course1)); for (int i = 0; i < 5; i++) { Assert.IsTrue(day1.Fit(course2)); } Assert.IsFalse(day1.Fit(course2)); }
public void Fit_OnlyOnce() { broom1 = new BookableRoom(start, end, room); broom2 = (BookableRoom)broom1.Clone(); broomList1 = new List<BookableRoom>() { broom1, broom2 }; day1 = new Day(broomList1); Assert.IsTrue(day1.Fit(course1)); var fits = day1.Rooms.Where(roomX => roomX.IsCourseBooked(course1)).ToList(); Assert.AreEqual(1, fits.Count); }
public void init() { resource1 = new Resource("TV"); resource2 = new Resource("Projector"); resource3 = new Resource("PC"); resources1 = new List<Resource>() { resource1, resource2 }; resources2 = new List<Resource>() { resource3 }; room1 = new Room(10, resources1); room2 = new Room(10, resources2); start = DateTime.Now; end = start.AddMinutes(5); broom1 = new BookableRoom(start, end, room1); broom2 = new BookableRoom(end.AddMinutes(1), end.AddMinutes(6), room2); broom3 = new BookableRoom(end.AddMinutes(2), end.AddMinutes(7), room2); course1 = new Course(1, 10, resources1); course2 = new Course(1, 10, resources2); course3 = new Course(1, 20, new List<Resource>() { new Resource("CoffeeMachine")}); broomList = new List<BookableRoom>() { broom1, broom2 }; broomList2 = new List<BookableRoom>() { broom3 }; day1 = new Day(broomList); day2 = new Day(broomList2); table1 = new Timetable(new List<Day>() { day1, day2 }); table2 = new Timetable(new List<Day>() { day1 }); }