예제 #1
0
        public void DontShouldInstantiateAHotelChainWhenDontHaveAtLeastOneHotel()
        {
            //Arrange
            var hotels = new List <Hotel>();

            //Action
            var(hotelChain, result) = HotelChain.Construct(hotels);

            //Assert
            Assert.False(result);
            Assert.Null(hotelChain);
        }
예제 #2
0
        static void Main(string[] args)
        {
            args[0] = args[0].Replace(":", "");
            var resultEnumTryParse = Enum.TryParse(typeof(CustomerType), args[0], false, out var customerType);

            if (!resultEnumTryParse)
            {
                Utils.Error("Não foi encontrado o tipo de cliente informado.");
            }

            var daysAmount = Utils.CountDaysAmount(args);

            var interError = "Houve um erro interno referente a rede de hoteis.";

            var(nerio, resultNerio) = Hotel.Construct("Nerio", 3, 110, 90, 80, 80);
            if (!resultNerio)
            {
                Utils.Error(interError);
            }

            var(coimbra, resultCoimbra) = Hotel.Construct("Coimbra", 4, 160, 60, 110, 50);
            if (!resultCoimbra)
            {
                Utils.Error(interError);
            }

            var(manso, resultManso) = Hotel.Construct("Manso", 5, 220, 150, 100, 40);
            if (!resultManso)
            {
                Utils.Error(interError);
            }

            var hotels = new List <Hotel> {
                nerio !, coimbra !, manso !
            };

            var(hotelChain, resultHotelChain) = HotelChain.Construct(hotels);
            if (!resultHotelChain)
            {
                Utils.Error(interError);
            }

            var(hotelCheaper, resultHotelCheaper) = hotelChain.CalculateCheaper((CustomerType)customerType, daysAmount.weekDaysAmount, daysAmount.weekendDaysAmount);
            if (!resultHotelCheaper)
            {
                Utils.Error(interError);
            }

            Console.WriteLine($"O Hotel mais barato da rede é o: {hotelCheaper}");
        }
    }
예제 #3
0
        public void ShouldInstantiateWithSuccessAHotelChain()
        {
            //Arrange
            var(nerio, _)   = Hotel.Construct("Nerio", 3, 110, 80, 90, 80);
            var(coimbra, _) = Hotel.Construct("Coimbra", 4, 160, 110, 60, 50);
            var(manso, _)   = Hotel.Construct("Manso", 5, 220, 100, 150, 40);

            var hotels = new List <Hotel> {
                nerio !, coimbra !, manso !
            };

            //Action
            var(hotelChain, result) = HotelChain.Construct(hotels);

            //Assert
            Assert.NotNull(hotelChain);
            Assert.True(result);

            Assert.Equal(hotels.Count, hotelChain !.Quantity);
        }
예제 #4
0
        public void ShouldIndicateTheHotelCheaperAtThePeriodOfDatesOfAReservationAndTheTypeOfCustomer(CustomerType customerType, int weekDaysAmount, int weekendDaysAmount, string expectedResult)
        {
            //Arrange
            var(nerio, _)   = Hotel.Construct("Nerio", 3, 110, 90, 80, 80);
            var(coimbra, _) = Hotel.Construct("Coimbra", 4, 160, 60, 110, 50);
            var(manso, _)   = Hotel.Construct("Manso", 5, 220, 150, 100, 40);

            var hotels = new List <Hotel> {
                nerio !, coimbra !, manso !
            };

            var(hotelChain, _) = HotelChain.Construct(hotels);

            //Action
            var(hotelCheaper, result) = hotelChain !.CalculateCheaper(customerType, weekDaysAmount, weekendDaysAmount);

            //Assert
            Assert.True(result);

            Assert.NotNull(hotelCheaper);
            Assert.NotEmpty(hotelCheaper);
            Assert.Equal(expectedResult, hotelCheaper);
        }
    }