Пример #1
0
        public void AddParticipantAsStudentOwner()
        {
            var server          = new ServerWithState();
            var loggedinuser    = server.student1;
            var useraddnotowner = server.sd1;
            var useraddowner    = server.teacher1;
            var reservation     = server.reservationD;

            var controller = new ReservationsController(server.server.database);

            controller.SetUserIdentity(loggedinuser);

            var result = controller.AddParticipants(server.server.EmailService, new List <int>()
            {
                useraddowner.Id
            }, new List <int>()
            {
                useraddnotowner.Id
            }, reservation.Id);

            Assert.IsType <OkObjectResult>(result);
            Assert.True(server.server.database.Participants.Where(x => x.User == loggedinuser).Where(x => x.ReservationID == reservation.Id).Where(x => x.IsOwner == true).Count() == 1);
            Assert.True(server.server.database.Participants.Where(x => x.User == useraddnotowner).Where(x => x.ReservationID == reservation.Id).Where(x => x.IsOwner == false).Count() == 1);
            Assert.True(server.server.database.Participants.Where(x => x.User == useraddowner).Where(x => x.ReservationID == reservation.Id).Where(x => x.IsOwner == true).Count() == 1);
        }
Пример #2
0
        public void GetID()
        {
            var server     = new ServerWithState();
            var controller = new ReservationsController(server.server.database);
            var result     = controller.GetMatch(server.reservationA.Id, null, null, null, null, null, null);

            Assert.True(result.ToHashSet().SetEquals(new Reservation[] { server.reservationA }));
        }
Пример #3
0
        public void GetBetweenDates()
        {
            var server     = new ServerWithState();
            var controller = new ReservationsController(server.server.database);
            var result     = controller.GetMatch(null, null, null, null, null, new DateTime(2000, 1, 4, 10, 0, 0), new DateTime(2000, 1, 8, 10, 0, 0));

            Assert.True(result.ToHashSet().SetEquals(new Reservation[] { server.reservationC, server.reservationD }));
        }
Пример #4
0
        public void GetAllReservations()
        {
            var server     = new ServerWithState();
            var controller = new ReservationsController(server.server.database);
            var result     = controller.GetMatch(null, null, null, null, null, null, null);

            Assert.True(result.ToHashSet().SetEquals(new Reservation[] { server.reservationA, server.reservationB, server.reservationC, server.reservationD, server.reservationE, server.reservationF, server.reservationG }));
        }