예제 #1
0
        public void EstimateTotalRental_Tests()
        {
            const decimal expectedEstimatePurchasedFeaturesFee = 99;
            const decimal expectedFeePerDay = 1;
            const decimal expectedFeePerTraveledMetricUnit = 2;
            const decimal expectedResult = 102;

            availableRentalFeaturesMock.Setup(x => x.EstimatePurchasedFeaturesFee()).Returns(expectedEstimatePurchasedFeaturesFee);

            vehiculeMock.Setup(v => v.FeePerDay).Returns(expectedFeePerDay);
            vehiculeMock.Setup(v => v.FeePerTraveledMetricUnit).Returns(expectedFeePerTraveledMetricUnit);

            availableVehiculesMock.Setup(v => v.GetRentalVehicule()).Returns(vehiculeMock.Object);

            rental = new Rental(availableVehiculesMock.Object, availableRentalFeaturesMock.Object, 1, 1);

            Assert.AreEqual(expectedResult,
                            rental
                            .EstimateRentalPeriodFee()
                            .EstimateTraveledDistanceFee()
                            .EstimatePurchasedFeaturesFee()
                            .EstimateTotalRental()
                            .CalculatedTotalRental);

            availableRentalFeaturesMock.Verify(x => x.EstimatePurchasedFeaturesFee(), Times.Once);
        }
예제 #2
0
 public Bike(string identificationCode, BikeSpecifications specifications)
 {
     this.IdentificationCode = identificationCode;
     this.Specifications     = specifications;
     this.State  = BikeState.Free;
     this.Rental = null;
 }
예제 #3
0
 public void ReturnBook(IRental model)
 {
     _unitOfWork.Get <Book>(model.BookId).RentedBooks--;
     _unitOfWork.Get <Customer>(model.CustomerId).RentedBooks--;
     _unitOfWork.Get <Rental>(model.Id).DateReturned = DateTime.Now;
     _unitOfWork.Commit();
 }
예제 #4
0
        public void RentVehicule_Tests()
        {
            availableVehiculesMock.Setup(x => x.RentVehicule <IVehicule>()).Returns(availableVehiculesMock.Object);

            rental = new Rental(availableVehiculesMock.Object, availableRentalFeaturesMock.Object, 0, 0);

            rental.RentVehicule <IVehicule>();
            availableVehiculesMock.Verify(x => x.RentVehicule <IVehicule>(), Times.Once);
        }
예제 #5
0
        public virtual void AddRental(IRental rental)
        {
            if (rental == null)
            {
                throw new ArgumentNullException();
            }

            rentals.Add(rental);
        }
예제 #6
0
        public IPaymentResponse Pay(ICreditCard card, IRental rental)
        {
            Transaction transaction = new Transaction();

            //transaction.amount
            //           transaction.payee
            //transaction.payment_options.

            return(default(IPaymentResponse));
        }
예제 #7
0
        public void EstimatePurchasedFeaturesFee_Tests()
        {
            const decimal expectedResult = 99;

            availableRentalFeaturesMock.Setup(x => x.EstimatePurchasedFeaturesFee()).Returns(expectedResult);

            rental = new Rental(availableVehiculesMock.Object, availableRentalFeaturesMock.Object, 0, 0);

            Assert.AreEqual(expectedResult, rental.EstimatePurchasedFeaturesFee().CalculatedPurchasedFeaturesFee);
            availableRentalFeaturesMock.Verify(x => x.EstimatePurchasedFeaturesFee(), Times.Once);
        }
예제 #8
0
        public void Car_EstimateTraveledDistanceFee_Tests(decimal traveledMetricUnits, decimal expectedFeePerTraveledMetricUnit)
        {
            rental = new Rental(availableVehiculesMock.Object, availableRentalFeaturesMock.Object, traveledMetricUnits, 0);
            availableVehiculesMock.Setup(v => v.GetRentalVehicule()).Returns(new Car());

            Assert.AreEqual(
                expectedFeePerTraveledMetricUnit,
                rental.EstimateTraveledDistanceFee().CalculatedEstimateTraveledDistanceFee);

            availableVehiculesMock.Verify(v => v.GetRentalVehicule(), Times.Once);
        }
예제 #9
0
        public void MotorHome_EstimateRentalPeriodFee_Tests(int rentalDaysPeriod, decimal expectedRentalPeriodFee)
        {
            rental = new Rental(availableVehiculesMock.Object, availableRentalFeaturesMock.Object, 0, rentalDaysPeriod);
            availableVehiculesMock.Setup(v => v.GetRentalVehicule()).Returns(new MotorHome());

            Assert.AreEqual(
                expectedRentalPeriodFee,
                rental.EstimateRentalPeriodFee().CalculatedRentalPeriodFee);

            availableVehiculesMock.Verify(v => v.GetRentalVehicule(), Times.Once);
        }
예제 #10
0
        public void GetRentalVehicule_Tests()
        {
            availableVehiculesMock.Setup(x => x.GetRentalVehicule()).Returns(vehiculeMock.Object);

            rental = new Rental(availableVehiculesMock.Object, availableRentalFeaturesMock.Object, 0, 0);

            var actualResult = rental.GetRentalVehicule();

            availableVehiculesMock.Verify(x => x.GetRentalVehicule(), Times.Once);
            Assert.AreEqual(vehiculeMock.Object, actualResult);
        }
예제 #11
0
        public static decimal Cost(this IRental rental, DateTime from, DateTime to)
        {
            switch (rental.PerUnit)
            {
            case RentalUnit.PerDay:
                return(rental.Price * from.Subtract(to).Days);

            default:
                throw new ArgumentException("unknown unit");
            }
        }
예제 #12
0
        public void GetPurchasedFeatures_Tests()
        {
            var expectedResult = new List <IRentalFeature>();

            availableRentalFeaturesMock.Setup(x => x.GetPurchasedFeatures()).Returns(expectedResult);

            rental = new Rental(availableVehiculesMock.Object, availableRentalFeaturesMock.Object, 0, 0);

            Assert.AreSame(expectedResult, rental.GetPurchasedFeatures());
            availableRentalFeaturesMock.Verify(x => x.GetPurchasedFeatures(), Times.Once);
        }
예제 #13
0
        public void Add(IRental rental)
        {
            if (rental is Rental)
            {
                var book = _unitOfWork.Get <Book>(rental.BookId);
                book.RentedBooks++;

                var customer = _unitOfWork.Get <Customer>(rental.CustomerId);
                customer.RentedBooks++;
                _unitOfWork.Add <Rental>(rental as Rental);
                _unitOfWork.Commit();
            }
        }
예제 #14
0
        public RentalFinalization FinalizeRental(IClient client, IRental rental)
        {
            if (rental.IsFinalized())
            {
                throw new RentalIsAlreadyFinalizedException("Rental is already finalized");
            }

            RentalFinalization rentalFinalization = new RentalFinalization(client, this);

            rental.Finalization = rentalFinalization;

            Bike bike = rental.Bike;

            bike.ChangeState(BikeState.Free);
            bike.Rental = null;

            return(rentalFinalization);
        }
예제 #15
0
        public void SetUp()
        {
            this.Cashier = new Cashier();

            this.MockClient = new Mock <IClient>();

            this.MockRentalOperator = new Mock <IRentalOperator>();
            RentalBeginning rentalBeginning = new RentalBeginning(this.MockRentalOperator.Object);

            BikeSpecifications bikeSpecifications = new BikeSpecifications(TestsConstants.BIKE_BRAND,
                                                                           TestsConstants.BIKE_MODEL, TestsConstants.BIKE_COLOR);
            Bike bike = new Bike(TestsConstants.BIKE_IDENTIFICATION_CODE, bikeSpecifications);

            RentalModality rentalModality = new RentalByDay(new Money(TestsConstants.RENTAL_BY_DAY_AMOUNT,
                                                                      TestsConstants.RENTAL_BY_DAY_TYPE_OF_CURRENCY));

            this.Rental = new Rental(this.MockClient.Object, rentalBeginning, bike, rentalModality);
        }
예제 #16
0
 public RefuelOnReturnDecorator(IRental rentalInstance, float price) : base(rentalInstance)
 {
     refuelPrice = price;
 }
예제 #17
0
 public RentalFinalization FinalizeRental(IRental rental, IRentalOperator rentalOperator)
 {
     return(rentalOperator.FinalizeRental(this, rental));
 }
예제 #18
0
 public ProductController(IRentalAsset assets, IRental rentals, IGuitar guitars)
 {
     _assets  = assets;
     _rentals = rentals;
     _guitars = guitars;
 }
 public InsuranceRentalDecorator(IRental rentalInstance, float rate) : base(rentalInstance)
 {
     insuranceRate = rate;
 }
        //hasInsurance = true;

        public InsuranceRental(IRental rentalInstance, float rate)
        {
            rental        = rentalInstance;
            insuranceRate = rate;
        }
예제 #21
0
 public GameApplication(IGame game, IRental rental, IMapper mapper)
 {
     _game   = game;
     _rental = rental;
     _mapper = mapper;
 }
예제 #22
0
 public RentalApplication(IRental rental, IMapper mapper)
 {
     _rental = rental;
     _mapper = mapper;
 }
 public CarRentalDecorator(IRental instance)
 {
     rental = instance;
 }
예제 #24
0
 public void AddRental(IRental rental)
 {
     this.Rentals.Add(rental);
 }
예제 #25
0
 public void AddRental(IRental rental)
 {
     _rentals.Add(rental);
 }