コード例 #1
0
        public void FindByIdWithException()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);

            hrs.FindById(-5);
        }
コード例 #2
0
        public void DeleteReservationTestWithException()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);

            hrs.DeleteReservation(-5);
        }
コード例 #3
0
        public void ReserveTestWithException()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);

            hrs.Reserve(null);
        }
コード例 #4
0
        public void GivenWeekDayandWeekEnd_ReturnCheapestHotel_SadCase()
        {
            Customer customer = new Customer(CustomerType.REGULAR);

            string[] dates = { "11-09-2020", "12-09-2020" };
            HotelReservationService reservation = new HotelReservationService();
            string output = reservation.getCheapestHotel(customer, hotels, dates);

            Assert.AreEqual(output, "Hotel: LakeWood, Rate: 210");
        }
コード例 #5
0
        public void GivenHotelNames_ReturnCheapestHotel()
        {
            Customer customer = new Customer(CustomerType.REGULAR);

            string[] dates = { "2020-10-01", "2020-10-02" };
            HotelReservationService reservation = new HotelReservationService();
            string output = reservation.getCheapestHotel(customer, hotels, dates);

            Assert.AreEqual(output, "Hotel: LakeWood, Rate: 220");
        }
コード例 #6
0
        public void DeleteReservationTest()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);
            int numEx = uow.Object.HotelReservations.Get().Count - 1;

            HotelReservation reservation = uow.Object.HotelReservations.Get()[uow.Object.HotelReservations.Get().Count - 1];

            hrs.DeleteReservation(reservation.HotelReservationId);

            Assert.AreEqual(numEx, uow.Object.HotelReservations.Get().Count);
        }
コード例 #7
0
        public void FindByIdTest()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);

            HotelReservation    reservation = uow.Object.HotelReservations.Get()[uow.Object.HotelReservations.Get().Count - 1];
            HotelReservationDTO res         = hrs.FindById(reservation.HotelReservationId);

            Assert.AreEqual(reservation.ClientName, res.ClientName);
            Assert.AreEqual(reservation.Hotel.Name, res.Hotel.Name);
            Assert.AreEqual(reservation.StartDate, res.StartDate);
            Assert.AreEqual(reservation.EndDate, res.EndDate);
        }
コード例 #8
0
        public void ReserveTest()
        {
            ResetData();
            var uow = new Mock <UnitOfWork>();
            HotelReservationService hrs = new HotelReservationService(uow.Object);
            int numEx = uow.Object.HotelReservations.Get().Count + 1;

            HotelReservationDTO reservation = new HotelReservationDTO()
            {
                NumberOfPersons = 2,
                ClientName      = "ewf",
                Hotel           = Mapper.Map <HotelDTO>(uow.Object.Hotels.Get()[0]),
                StartDate       = DateTime.Now,
                EndDate         = DateTime.Now
            };

            hrs.Reserve(reservation);

            Assert.AreEqual(numEx, uow.Object.HotelReservations.Get().Count);
        }
コード例 #9
0
        public void Givendates_GetHighestRatedHotel()
        {
            Customer customer = new Customer(CustomerType.REGULAR);

            Hotel BridgeWood = new Hotel(customer, 160, 60);
            Hotel RidgeWood  = new Hotel(customer, 220, 150);
            Hotel LakeWood   = new Hotel(customer, 110, 90);

            hotels.Add(BridgeWood);
            hotels.Add(RidgeWood);
            hotels.Add(LakeWood);

            hotels[0].setRatingForHotel(4);
            hotels[1].setRatingForHotel(5);
            hotels[2].setRatingForHotel(3);

            string[] dates = { "11-09-2020", "12-09-2020" };
            HotelReservationService reservation = new HotelReservationService();
            string output = reservation.getHighestRatedHotel(customer, hotels, dates);

            Assert.AreEqual("Hotel: RidgeWood, Rate: 370, Rating: 5", output);
        }
コード例 #10
0
        public void GivenWeekDayandWeekEnd_ReturnCheapestHotelRewardCustomer()
        {
            List <Hotel> RewardCustomersHotelList = new List <Hotel>();
            Customer     customer = new Customer(CustomerType.REWARD);

            Hotel BridgeWood = new Hotel(customer, 160, 60);
            Hotel RidgeWood  = new Hotel(customer, 220, 150);
            Hotel LakeWood   = new Hotel(customer, 110, 90);

            RewardCustomersHotelList.Add(BridgeWood);
            RewardCustomersHotelList.Add(RidgeWood);
            RewardCustomersHotelList.Add(LakeWood);

            RewardCustomersHotelList[0].setRatingForHotel(4);
            RewardCustomersHotelList[1].setRatingForHotel(5);
            RewardCustomersHotelList[2].setRatingForHotel(3);

            string[] dates = { "12-09-2020", "13-09-2020" };
            HotelReservationService reservation = new HotelReservationService();
            string output = reservation.getCheapestBestRatedHotel(customer, hotels, dates);

            Assert.AreEqual("Hotel: Ridgewood, Rate: 140, Rating: 5", output);
        }