Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 public bool Equals(Day other)
 {
     if (other == null)
     {
         return false;
     }
     if (Number != other.Number)
     {
         return false;
     }
     if (Rooms.Count != other.Rooms.Count)
     {
         return false;
     }
     if (!Rooms.UnorderedEquals(other.Rooms))
     {
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public void Equals_DifferentRooms_No()
 {
     day2 = new Day(new List<BookableRoom>() { new BookableRoom(start, end, new Room("test", 10, null)) });
     Assert.AreNotEqual(day1, day2);
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public void GetHashCode_DifferentFields_DifferentHashCode()
 {
     day1 = new Day(new List<BookableRoom>() { broom1 });
     day2 = new Day(new List<BookableRoom>() { broom2 });
     Assert.AreNotEqual(day1, day2);
     Assert.AreNotEqual(day1.GetHashCode(), day2.GetHashCode());
 }
Ejemplo n.º 7
0
        public void GetHashCode_Clone_SameHashCode()
        {
            day2 = (Day)day1.Clone();

            Assert.AreEqual(day1, day2);
            Assert.AreEqual(day1.GetHashCode(), day2.GetHashCode());
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 public object Clone()
 {
     Day clone = new Day(Number, (List<BookableRoom>)Rooms.Clone());
     return clone;
 }
Ejemplo n.º 11
0
        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 });
        }
Ejemplo n.º 12
0
        public void Fit_OnlyOnce()
        {
            broomList = new List<BookableRoom>() { broom1 };
            broomList2 = new List<BookableRoom>() { (BookableRoom) broom1.Clone() };
            day1 = new Day(broomList);
            day2 = new Day(broomList2);

            table1 = new Timetable(new List<Day>() { day1, day2 });
            Assert.IsTrue(table1.Fit(course1));

            var fits = table1.Days.Where(day => day.IsCourseBooked(course1)).ToList();
            Assert.AreEqual(1, fits.Count);
        }
Ejemplo n.º 13
0
        public void Equals_SameDays_Yes()
        {
            day1 = new Day(broomList);
            day2 = new Day(broomList);

            table1 = new Timetable(new List<Day>() { day1 });
            table2 = new Timetable(new List<Day>() { day2 });

            Assert.AreEqual(table1, table2);
        }