Ejemplo n.º 1
0
        public void Mutation_DeleteServicesDetail_InvalidBooking_Status()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Booking
                {
                    Id               = 200,
                    Status           = (int)Booking.StatusEnum.CheckedOut,
                    EmployeeBooking  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckIn  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckOut = EmployeeDataAccess.Get("admin"),
                    Bill             = BillDataAccess.Get(1),
                    Room             = RoomDataAccess.Get(1)
                });
                realm.Add(new ServicesDetail
                {
                    Id      = 11,
                    Booking = BookingBusiness.Get(1),
                    Service = ServiceBusiness.Get(200),
                    Number  = 10
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Phòng đã check-out. Không thể cập nhật/xóa chi tiết dịch vụ",
                @"/_GraphQL/ServicesDetail/mutation.deleteServicesDetail.gql",
                new { id = 11 },
                p => p.PermissionCleaning = true
                );
        }
Ejemplo n.º 2
0
 public void Mutation_RequestCheckOut()
 {
     Database.WriteAsync(realm => realm.Add(new Booking
     {
         Id               = 30,
         Status           = (int)Booking.StatusEnum.CheckedIn,
         EmployeeBooking  = EmployeeDataAccess.Get("admin"),
         EmployeeCheckIn  = EmployeeDataAccess.Get("admin"),
         EmployeeCheckOut = EmployeeDataAccess.Get("admin"),
         Bill             = BillDataAccess.Get(1),
         Room             = RoomDataAccess.Get(1)
     })).Wait();
     SchemaHelper.Execute(
         @"/_GraphQL/Booking/mutation.requestCheckOut.gql",
         @"/_GraphQL/Booking/mutation.requestCheckOut.schema.json",
         new { id = 30 },
         p => p.PermissionManageRentingRoom = true
         );
 }
Ejemplo n.º 3
0
 public void Mutation_CheckOut_InvalidBookingStatus()
 {
     Database.WriteAsync(realm => realm.Add(new Booking
     {
         Id               = 21,
         Status           = (int)Booking.StatusEnum.CheckedIn,
         EmployeeBooking  = EmployeeDataAccess.Get("admin"),
         EmployeeCheckIn  = EmployeeDataAccess.Get("admin"),
         EmployeeCheckOut = EmployeeDataAccess.Get("admin"),
         Bill             = BillDataAccess.Get(1),
         Room             = RoomDataAccess.Get(1)
     })).Wait();
     SchemaHelper.ExecuteAndExpectError(
         "Booking chưa thực hiện yêu cầu check-out",
         @"/_GraphQL/Booking/mutation.checkOut.gql",
         new { id = 21 },
         p => p.PermissionManageRentingRoom = true
         );
 }
Ejemplo n.º 4
0
        public void Mutation_RequestCheckOut_InvalidBookingStatus()
        {
            Database.WriteAsync(realm => realm.Add(new Booking
            {
                Id               = 31,
                Status           = (int)Booking.StatusEnum.CheckedOut,
                EmployeeBooking  = EmployeeDataAccess.Get("admin"),
                EmployeeCheckIn  = EmployeeDataAccess.Get("admin"),
                EmployeeCheckOut = EmployeeDataAccess.Get("admin"),
                Bill             = BillDataAccess.Get(1),
                Room             = RoomDataAccess.Get(1)
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Không thể yêu cầu trả phòng",
                @"/_GraphQL/Booking/mutation.requestCheckOut.gql",
                new { id = 31 },
                p => p.PermissionManageRentingRoom = true
                );
        }
Ejemplo n.º 5
0
        public void Mutation_CheckIn_InvalidBookingStatus()
        {
            Database.WriteAsync(realm => realm.Add(new Booking
            {
                Id               = 11,
                Status           = (int)Booking.StatusEnum.CheckedIn,
                EmployeeBooking  = EmployeeDataAccess.Get("admin"),
                EmployeeCheckIn  = null,
                EmployeeCheckOut = null,
                Bill             = BillDataAccess.Get(1),
                Room             = RoomDataAccess.Get(1)
            })).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Phòng đã được check-in, không thể check-in lại",
                @"/_GraphQL/Booking/mutation.checkIn.gql",
                new { id = 11 },
                p => p.PermissionManageRentingRoom = true
                );
        }
Ejemplo n.º 6
0
        public void Mutation_CheckOut_InvalidEmployee()
        {
            Database.WriteAsync(realm =>
            {
                realm.Add(new Employee
                {
                    Id           = "nhanvien_1",
                    Address      = "Địa chỉ",
                    IsActive     = true,
                    Birthdate    = DateTimeOffset.Now,
                    Email        = "*****@*****.**",
                    Gender       = true,
                    Name         = "Quản trị viên",
                    IdentityCard = "123456789",
                    Password     = CryptoHelper.Encrypt("12345678"),
                    PhoneNumber  = "+84 0123456789",
                    Position     = PositionBusiness.Get(1),
                    StartingDate = DateTimeOffset.Now
                });
                realm.Add(new Booking
                {
                    Id               = 22,
                    Status           = (int)Booking.StatusEnum.RequestedCheckOut,
                    EmployeeBooking  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckIn  = EmployeeDataAccess.Get("admin"),
                    EmployeeCheckOut = EmployeeDataAccess.Get("nhanvien_1"),
                    Bill             = BillDataAccess.Get(1),
                    Room             = RoomDataAccess.Get(1)
                });
            }).Wait();

            SchemaHelper.ExecuteAndExpectError(
                "Nhân viên không được phép check-out",
                @"/_GraphQL/Booking/mutation.checkOut.gql",
                new { id = 22 },
                p => p.PermissionManageRentingRoom = true
                );
        }
Ejemplo n.º 7
0
 public static IEnumerable <Room> Get() => RoomDataAccess.Get();
Ejemplo n.º 8
0
 public static Room Get(int roomId) => RoomDataAccess.Get(roomId);