public void checkGenerateReport()
        {
            double report = HotelRoomReservation.totalAmountOfRoomRent("regular", new string[] { "2018/7/7", "2018/6/6" });

            Assert.AreEqual(1100, report);
            Assert.AreNotEqual(1000, report);
        }
Example #2
0
        public void ReserveRoom(int UserId, int HotelId, int HotelRoomId, DateTimeOffset ArrivalDate, DateTimeOffset DepartureDate)
        {
            if (CurrentUser == null)
            {
                throw new WrongUserException("Login to reserve room");
            }
            User      user      = UoW.Users.GetAll(u => u.Id == UserId, u => u.HotelRoomReservations).FirstOrDefault();
            HotelRoom hotelroom = UoW.Hotels.GetAll(h => h.Id == HotelId, h => h.Rooms).FirstOrDefault().Rooms.FirstOrDefault(r => r.Id == HotelRoomId);

            foreach (DateTimeOffset d in hotelroom.BookedDays)
            {
                DateTimeOffset FakeArrival   = ArrivalDate;
                DateTimeOffset FakeDeparture = DepartureDate;
                while (FakeArrival.CompareTo(FakeDeparture) < 0)
                {
                    if ((d.Date.CompareTo(FakeArrival.Date) == 0))
                    {
                        throw new AlreadyBookedItemException("Room is not availible for " + d.Day + "." + d.Month + "." + d.Year);
                    }
                    FakeArrival = FakeArrival.AddDays(1);
                }
            }
            var reserv = new HotelRoomReservation(hotelroom, user.Name, user.Surname, ArrivalDate.Date, DepartureDate.Date);

            while (ArrivalDate.CompareTo(DepartureDate) < 0)
            {
                hotelroom.BookedDays.Add(ArrivalDate.Date);
                ArrivalDate = ArrivalDate.AddDays(1);
            }
            UoW.HotelsRooms.Modify(hotelroom.Id, hotelroom);
            UoW.HotelsRoomsReservations.Add(reserv);
            user.HotelRoomReservations.Add(reserv);
            UoW.Users.Modify(user.Id, user);
        }
        public void checkWeekendOrNot()
        {
            double roomRent   = HotelRoomReservation.checkWeekEnd("2018/7/23");
            double roomRent_I = HotelRoomReservation.checkWeekEnd("2018/7/29");

            Assert.AreEqual(500, roomRent);
            Assert.AreNotEqual(600, roomRent);
            Assert.AreEqual(600, roomRent_I);
            Assert.AreNotEqual(500, roomRent_I);
        }
        public void checkRoomRentDiscount()
        {
            double discountAmount    = HotelRoomReservation.roomRentDiscount("Regular", 1200);
            double discountAmount_I  = HotelRoomReservation.roomRentDiscount("Rewarded", 1000);
            double discountAmount_II = HotelRoomReservation.roomRentDiscount("Rewarded", 600);

            Assert.AreEqual(0.0, discountAmount);
            Assert.AreNotEqual(1150, discountAmount);
            Assert.AreEqual(50, discountAmount_I);
            Assert.AreNotEqual(0.0, discountAmount_I);
            Assert.AreEqual(0.0, discountAmount_II);
        }
        public void checkSplitingMethod()
        {
            string[] afterSplitAsColen = HotelRoomReservation.splitDataAsGivenCharacter("type:date,date", ':');
            string[] afterSplitAsComma = HotelRoomReservation.splitDataAsGivenCharacter("date,date", ',');
            string[] afterSplitAsSlash = HotelRoomReservation.splitDataAsGivenCharacter("23/7/2018", '/');

            CollectionAssert.AreEqual(new string[] { "type", "date,date" }, afterSplitAsColen);
            CollectionAssert.AreNotEqual(new string[] { "type:", "date,date" }, afterSplitAsColen);
            CollectionAssert.AreEqual(new string[] { "date", "date" }, afterSplitAsComma);
            CollectionAssert.AreNotEqual(new string[] { "date,", "date," }, afterSplitAsComma);
            CollectionAssert.AreEqual(new string[] { "23", "7", "2018" }, afterSplitAsSlash);
            CollectionAssert.AreNotEqual(new string[] { "7", "23", "2018" }, afterSplitAsSlash);
        }