Ejemplo n.º 1
0
        public void LimousineTest_Methods()
        {
            List <Arangement> arangements = new List <Arangement>
            {
                new Wedding(2000),
                new Wellness(3200),
                new Airport(),
                new Business(),
                new Nightlife(2500)
            };
            Limousine limousine  = new Limousine(100, "Tesla Model X", 10, arangements);
            int       price      = 2000;
            DateTime  dateNeeded = new DateTime(2000, 2, 23, 10, 0, 0);

            limousine.PriceForArangement(dateNeeded, "Wedding", startHour: new TimeSpan(7, 0, 0)).Key.Should().Be(price);
            price      = 3200;
            dateNeeded = new DateTime(2000, 2, 25, 10, 0, 0);

            limousine.PriceForArangement(dateNeeded, "Wellness", startHour: new TimeSpan(7, 0, 0)).Key.Should().Be(price);
            price      = 2500;
            dateNeeded = new DateTime(2000, 2, 24, 10, 0, 0);

            limousine.PriceForArangement(dateNeeded, "Nightlife", startHour: new TimeSpan(22, 0, 0)).Key.Should().Be(price);
            TimeSpan startHour = new TimeSpan(10, 0, 0);
            TimeSpan endHour   = new TimeSpan(15, 0, 0);

            price      = 360;
            dateNeeded = new DateTime(2000, 2, 27, 10, 0, 0);

            limousine.PriceForArangement(dateNeeded, "Airport", startHour: startHour, endHour: endHour).Key.Should().Be(price);
            dateNeeded = new DateTime(2000, 2, 29, 10, 0, 0);

            limousine.PriceForArangement(dateNeeded, "Business", startHour: startHour, endHour: endHour).Key.Should().Be(price);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates all prices.
        /// </summary>
        /// <param name="client">The client that reserved the limousine.</param>
        /// <param name="extraHours">Amount of extra hours added to the duration of the arangement (if applicable).</param>
        /// <param name="startHour">When the arangement starts (if applicable).</param>
        /// <param name="endHour">When the arangement ends (if applicable).</param>
        public void CalculatePrices(Client client, int?extraHours = null, TimeSpan?startHour = null, TimeSpan?endHour = null)
        {
            var result = Limousine.PriceForArangement(DateLimousineNeeded, Arangement, extraHours, startHour, endHour);

            Hours            = result.Value;
            SubTotal         = result.Key;
            UsedDiscount     = client.GetDiscount();
            AmountWithoutBtw = (int)(SubTotal - (SubTotal * (UsedDiscount / 100.0f)));
            BtwAmount        = (int)(AmountWithoutBtw * (BtwPercentage / 100.0f));
            ToPayAmount      = AmountWithoutBtw + BtwAmount;
        }
Ejemplo n.º 3
0
        public void LimousineTest_Exceptions()
        {
            List <Arangement> arangements = new List <Arangement>();
            Action            act         = () => new Limousine(100, "Tesla Model X", 0, arangements);

            act.Should().Throw <DomainException>().WithMessage("Een limousine moet minstens 1 keer beschikbaar zijn.");

            act = () => new Limousine(100, "Tesla Model X", 1, arangements);
            act.Should().Throw <DomainException>().WithMessage("Een limousine moet minstens 1 arangement hebben.");

            arangements.Add(new Airport());
            arangements.Add(new Airport());
            act = () => new Limousine(100, "Tesla Model X", 1, arangements);
            act.Should().Throw <DomainException>().WithMessage("Een limousine kan geen arangement 2 keer hebben.");

            DateTime dateNeeded = new DateTime(2000, 2, 27, 10, 0, 0);

            arangements = new List <Arangement>
            {
                new Wedding(2000)
            };
            Limousine limousine = new Limousine(100, "Tesla Model X", 1, arangements);

            act = () => limousine.PriceForArangement(dateNeeded, "Wedding");
            act.Should().Throw <DomainException>().WithMessage($"Het arangement Wedding heeft een start uur nodig.");

            limousine.PriceForArangement(dateNeeded, "Wedding", startHour: new TimeSpan(7, 0, 0));


            act = () => limousine.PriceForArangement(dateNeeded, "Wedding", startHour: new TimeSpan(7, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Limousine {limousine.Name} is niet vrij.");

            dateNeeded = new DateTime(2000, 2, 28, 10, 0, 0);
            act        = () => limousine.PriceForArangement(dateNeeded, "Wellness", startHour: new TimeSpan(7, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Limousine {limousine.Name} does not have a wellness arangement.");

            arangements = new List <Arangement>
            {
                new Wellness(3200)
            };
            limousine = new Limousine(100, "Tesla Model X", 10, arangements);
            act       = () => limousine.PriceForArangement(dateNeeded, "Wedding", startHour: new TimeSpan(7, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Limousine {limousine.Name} does not have a wedding arangement.");
            arangements.Add(new Wedding(2000));


            act = () => limousine.PriceForArangement(dateNeeded, "Nightlife");
            act.Should().Throw <DomainException>().WithMessage($"Het arangement Nightlife heeft een start uur nodig.");


            act = () => limousine.PriceForArangement(dateNeeded, "Nightlife", startHour: new TimeSpan(20, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Limousine {limousine.Name} does not have a nightlife arangement.");
            arangements.Add(new Nightlife(2500));


            act = () => limousine.PriceForArangement(dateNeeded, "Airport");
            act.Should().Throw <DomainException>().WithMessage($"Het arangement Airport heeft een start uur nodig.");

            act = () => limousine.PriceForArangement(dateNeeded, "Airport", startHour: new TimeSpan(10, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Het arangement Airport heeft een eind uur nodig.");

            act = () => limousine.PriceForArangement(dateNeeded, "Airport", startHour: new TimeSpan(10, 0, 0), endHour: new TimeSpan(18, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Limousine {limousine.Name} does not have a airport arangement.");
            arangements.Add(new Airport());

            act = () => limousine.PriceForArangement(dateNeeded, "Business");
            act.Should().Throw <DomainException>().WithMessage($"Het arangement Business heeft een start uur nodig.");

            act = () => limousine.PriceForArangement(dateNeeded, "Business", startHour: new TimeSpan(10, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Het arangement Business heeft een eind uur nodig.");

            act = () => limousine.PriceForArangement(dateNeeded, "Business", startHour: new TimeSpan(10, 0, 0), endHour: new TimeSpan(18, 0, 0));
            act.Should().Throw <DomainException>().WithMessage($"Limousine {limousine.Name} does not have a business arangement.");
            arangements.Add(new Business());
        }