public void GivenDuplicateHotel_ShouldThrowCustomException()
        {
            //Arrange
            Hotel     firstHotel  = new Hotel("LakeWood", 100);
            Hotel     secondHotel = new Hotel("LakeWood", 120);
            Exception exception   = new Exception();

            //Act
            try
            {
                MiamiHotels.HotelList.Clear();
                MiamiHotels.AddHotel(firstHotel);
                MiamiHotels.AddHotel(secondHotel);
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            catch (Exception e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "This hotel already exist");
        }
        public void GivenHotelRating_ShouldAddToHotelProperties()
        {
            //Arrange
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel("Lakewood", 120, 80);
            int expectedRating = 3;

            //Act
            MiamiHotels.AddRating("Lakewood", expectedRating);
            //Assert
            Assert.AreEqual(expectedRating, MiamiHotels.HotelList["Lakewood"].Rating);
        }
Example #3
0
        public void GivenWeekendRate_ShouldAddToHotelProperties()
        {
            //Arrange
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel("Lakewood", 120);
            double expectedWeekendRate = 80;

            //Act
            MiamiHotels.AddWeekendRate("Lakewood", expectedWeekendRate);
            //Assert
            Assert.AreEqual(expectedWeekendRate, MiamiHotels.HotelList["Lakewood"].WeekendRates);
        }
        public void GivenSpecialRates_ShouldAddToHotelProperties()
        {
            //Arrange
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel("Lakewood", 120, 90, 3);
            double expectedWeekdayRate = 80;
            double expectedWeekendRate = 80;

            //Act
            MiamiHotels.AddSpecialRates("Lakewood", expectedWeekdayRate, expectedWeekendRate);
            //Assert
            Assert.AreEqual(expectedWeekdayRate, MiamiHotels.HotelList["Lakewood"].SpecialNormalRate);
            Assert.AreEqual(expectedWeekendRate, MiamiHotels.HotelList["Lakewood"].SpecialWeekendRate);
        }
        public void GivenHotel_ShouldAddToReservationSystem()
        {
            //Arrange
            string expectedName = "BridgeWood";
            double expectedRate = 100;
            Hotel  hotel        = new Hotel(expectedName, expectedRate);

            //Act
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel(hotel);

            //Assert
            Assert.AreEqual(hotel.GetType(), MiamiHotels.HotelList[expectedName].GetType());
        }
        public void GivenNameAndRate_ShouldAddHotelToResvSystem()
        {
            //Arrange
            string expectedName = "LakeWood";
            double expectedRate = 90;

            //Act
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel(expectedName, expectedRate);

            //Assert
            Assert.AreEqual(expectedName, MiamiHotels.HotelList[expectedName].Name);
            Assert.AreEqual(expectedRate, MiamiHotels.HotelList[expectedName].WeekdayRates);
        }
        public void GivenNegativeHotelRating_ShouldThrowCustomException()
        {
            //Arrange
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel("Lakewood", 120, 80);
            Exception exception = new Exception();

            //Act
            try
            {
                MiamiHotels.AddRating("Lakewood", -3);
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual("Rating can not be negative", exception.Message);
        }
        public void GivenWrongHotelName_ShouldThrowCustomException()
        {
            //Arrange
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel("Lakewood", 120, 80);
            Exception exception = new Exception();

            //Act
            try
            {
                MiamiHotels.AddRating("lakewood", 3);    //testing typoerror
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual("Hotel do not exist", exception.Message);
        }
        public void GivenHotelNameAsNull_ShouldThrowCustomException()
        {
            //Arrange
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel("Lakewood", 120, 90);
            Exception exception = new Exception();

            //Act
            try
            {
                MiamiHotels.AddRating(null, 3);
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual("Hotel name can not be null", exception.Message);
        }
Example #10
0
        public void GivenZeroAsWeekendRate_ShouldThrowCustomException()
        {
            //Arrange
            MiamiHotels.HotelList.Clear();
            MiamiHotels.AddHotel("Lakewood", 120);
            Exception exception = new Exception();

            //Act
            try
            {
                MiamiHotels.AddWeekendRate("Lakewood", 0);
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual("Hotel rate can not be zero", exception.Message);
        }
        public void GivenNullHotelName_ShouldThrowCustomException()
        {
            //Arrange
            Hotel     hotel     = new Hotel(null, 100);
            Exception exception = new Exception();

            //Act
            try
            {
                MiamiHotels.HotelList.Clear();
                MiamiHotels.AddHotel(hotel);
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            catch (Exception e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "Hotel name can not be null");
        }
        public void GivenZeroHotelRate_ShouldThrowCustomException()
        {
            //Arrange
            Hotel     hotel     = new Hotel("RidgeWood", 0);
            Exception exception = new Exception();

            //Act
            try
            {
                MiamiHotels.HotelList.Clear();
                MiamiHotels.AddHotel(hotel);
            }
            catch (HotelReservationException e)
            {
                exception = e;
            }
            catch (Exception e)
            {
                exception = e;
            }
            //Assert
            Assert.AreEqual(exception.Message, "Hotel rate can not be zero");
        }