Esempio n. 1
0
        public void TestInitialize()
        {
            _repoRoom.Clear();

            _roomList = new List <IRoom>();

            _student = new User("matt2694", "*****@*****.**", Permission.Student);
            _teacher = new User("alhe", "*****@*****.**", Permission.Teacher);
            _admin   = new User("frje", "*****@*****.**", Permission.Admin);

            _room1 = new Room('A', 2, 9, 6, Permission.Student);
            _room2 = new Room('A', 2, 15, 6, Permission.Teacher);
            _room3 = new Room('A', 2, 115, 6, Permission.Admin);
            _room4 = new Room('A', 7, 5, 2, Permission.Student);
            _room5 = new Room('B', 7, 5, 10, Permission.Student);

            _repoRoom.Add(_room1);
            _repoRoom.Add(_room2);
            _repoRoom.Add(_room3);
            _repoRoom.Add(_room4);
            _repoRoom.Add(_room5);

            _dateFrom = new DateTime(2016, 4, 29, 8, 0, 0);
            _dateTo   = new DateTime(2016, 4, 29, 16, 0, 0);

            _reservation1 = new Reservation(_student, _room1, 6, _dateFrom, _dateTo);
            _reservation2 = new Reservation(_teacher, _room2, 6, _dateFrom, _dateTo);
            _reservation3 = new Reservation(_admin, _room3, 6, _dateFrom, _dateTo);
        }
        public void Init()
        {
            _repoReserv.Clear();
            _repoUser.Clear();
            _repoRoom.Clear();

            _room1 = new Room('A', 1, 49, 4, Permission.Student);
            _room2 = new Room('B', 2, 23, 6, Permission.Student);

            _student = new User("jona8690", "*****@*****.**", Permission.Student);

            _repoRoom.Add(_room1);
            _repoRoom.Add(_room2);
        }
        public void Init()
        {
            _repoReserv.Clear();
            _repoRoom.Clear();
            _repoUser.Clear();

            _room1   = new Room('A', 4, 49, 4, Permission.Student);
            _student = new User("hedv", "*****@*****.**", Permission.Student);

            _repoUser.Add(_student);
            _repoRoom.Add(_room1);

            _from = new DateTime(2017, 5, 8, 12, 0, 0);
            _to   = new DateTime(2017, 5, 8, 13, 0, 0);
        }
Esempio n. 4
0
        public void GetAllReservationsTest()
        {
            UserRepository repoUser  = UserRepository.Instance;
            RoomRepository repoRooms = RoomRepository.Instance;

            repoUser.Clear();
            repoRooms.Clear();

            DALFacade testDALFacade = new DALFacade();

            string username = "******";
            string building = "C";
            string floorNr  = "4";
            string nr       = "1000";
            string dateFrom = "2017-05-05 18:00:00.00";
            string dateTo   = "2017-05-05 19:00:00.00";
            string peopleNr = "1";

            List <Dictionary <string, string> > resultdReservationsInfo = new List <Dictionary <string, string> >();
            Dictionary <string, string>         oneReservation          = new Dictionary <string, string>();

            oneReservation.Add("Username", username);
            oneReservation.Add("Building", building);
            oneReservation.Add("FloorNr", floorNr);
            oneReservation.Add("Nr", nr);
            oneReservation.Add("DateFrom", dateFrom);
            oneReservation.Add("DateTo", dateTo);
            oneReservation.Add("PeopleNr", peopleNr);

            resultdReservationsInfo.Add(oneReservation);

            repoUser.Add(testUser);
            repoRooms.Add(testRoom);

            Reservation expectedReservation = new Reservation(testUser, testRoom, 1, testDateFrom, testDateTo);


            var mock = new Mock <DAL.IReservationsForMocking>();

            mock.Setup(reservationsMock => reservationsMock.GetAllReservationsFromDatabase()).Returns(() => resultdReservationsInfo);

            List <Reservation> returnedReservation = testDALFacade.ConvertFromStringsToReservationObjects(mock.Object.GetAllReservationsFromDatabase());

            Assert.AreEqual(expectedReservation, returnedReservation[0]);
        }
        public void TestsInitialize()
        {
            _repoRoom.Clear();
            _repoReserv.Clear();
            _repoUser.Clear();

            _room1 = new Room('A', 1, 2, 4, Permission.Student);
            _room2 = new Room('A', 1, 99, 8, Permission.Student);
            _room3 = new Room('B', 1, 45, 2, Permission.Student);

            _repoRoom.Add(_room1);
            _repoRoom.Add(_room2);
            _repoRoom.Add(_room3);

            _student = new User("roxa0198", "*****@*****.**", Permission.Student);

            _repoUser.Add(_student);
        }
Esempio n. 6
0
        public void GetAllReservationsTestForMultipleReservations()
        {
            repoUser.Clear();
            repoRooms.Clear();

            DALFacade testDALFacade = new DALFacade();

            string username1 = "matt2694";
            string building1 = "C";
            string floorNr1  = "4";
            string nr1       = "1000";
            string dateFrom1 = "2017-05-05 18:00:00.00";
            string dateTo1   = "2017-05-05 19:00:00.00";
            string peopleNr1 = "1";

            string username2 = "matt2694";
            string building2 = "C";
            string floorNr2  = "4";
            string nr2       = "1000";
            string dateFrom2 = "2017-05-06 18:00:00.00";
            string dateTo2   = "2017-05-06 19:00:00.00";
            string peopleNr2 = "1";

            string username3 = "matt2694";
            string building3 = "C";
            string floorNr3  = "4";
            string nr3       = "1000";
            string dateFrom3 = "2017-05-07 18:00:00.00";
            string dateTo3   = "2017-05-07 19:00:00.00";
            string peopleNr3 = "1";

            List <Dictionary <string, string> > resultdReservationsInfo = new List <Dictionary <string, string> >();
            Dictionary <string, string>         oneReservation1         = new Dictionary <string, string>();
            Dictionary <string, string>         oneReservation2         = new Dictionary <string, string>();
            Dictionary <string, string>         oneReservation3         = new Dictionary <string, string>();

            oneReservation1.Add("Username", username1);
            oneReservation1.Add("Building", building1);
            oneReservation1.Add("FloorNr", floorNr1);
            oneReservation1.Add("Nr", nr1);
            oneReservation1.Add("DateFrom", dateFrom1);
            oneReservation1.Add("DateTo", dateTo1);
            oneReservation1.Add("PeopleNr", peopleNr1);

            oneReservation2.Add("Username", username2);
            oneReservation2.Add("Building", building2);
            oneReservation2.Add("FloorNr", floorNr2);
            oneReservation2.Add("Nr", nr2);
            oneReservation2.Add("DateFrom", dateFrom2);
            oneReservation2.Add("DateTo", dateTo2);
            oneReservation2.Add("PeopleNr", peopleNr2);

            oneReservation3.Add("Username", username3);
            oneReservation3.Add("Building", building3);
            oneReservation3.Add("FloorNr", floorNr3);
            oneReservation3.Add("Nr", nr3);
            oneReservation3.Add("DateFrom", dateFrom3);
            oneReservation3.Add("DateTo", dateTo3);
            oneReservation3.Add("PeopleNr", peopleNr3);

            resultdReservationsInfo.Add(oneReservation1);
            resultdReservationsInfo.Add(oneReservation2);
            resultdReservationsInfo.Add(oneReservation3);

            DateTime testDateFrom1 = new DateTime(2017, 05, 05, 18, 00, 00, 00);
            DateTime testDateTo1   = new DateTime(2017, 05, 05, 19, 00, 00, 00);

            DateTime testDateFrom2 = new DateTime(2017, 05, 06, 18, 00, 00, 00);
            DateTime testDateTo2   = new DateTime(2017, 05, 06, 19, 00, 00, 00);

            DateTime testDateFrom3 = new DateTime(2017, 05, 07, 18, 00, 00, 00);
            DateTime testDateTo3   = new DateTime(2017, 05, 07, 19, 00, 00, 00);

            IUser testUser = new User(username1, "*****@*****.**", Permission.Student);
            IRoom testRoom = new Room('C', 4, 1000, 20, Permission.Student);

            repoUser.Add(testUser);
            repoRooms.Add(testRoom);

            Reservation expectedReservation1 = new Reservation(testUser, testRoom, 1, testDateFrom1, testDateTo1);
            Reservation expectedReservation2 = new Reservation(testUser, testRoom, 1, testDateFrom2, testDateTo2);
            Reservation expectedReservation3 = new Reservation(testUser, testRoom, 1, testDateFrom3, testDateTo3);

            var mock = new Mock <DAL.IReservationsForMocking>();

            mock.Setup(reservationsMock => reservationsMock.GetAllReservationsFromDatabase()).Returns(() => resultdReservationsInfo);

            List <Reservation> returnedReservation = testDALFacade.ConvertFromStringsToReservationObjects(mock.Object.GetAllReservationsFromDatabase());

            Assert.IsTrue(expectedReservation1.Equals(returnedReservation[0]) && expectedReservation2.Equals(returnedReservation[1]) && expectedReservation3.Equals(returnedReservation[2]));
        }