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); }
public Bike(string identificationCode, BikeSpecifications specifications) { this.IdentificationCode = identificationCode; this.Specifications = specifications; this.State = BikeState.Free; this.Rental = null; }
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(); }
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); }
public virtual void AddRental(IRental rental) { if (rental == null) { throw new ArgumentNullException(); } rentals.Add(rental); }
public IPaymentResponse Pay(ICreditCard card, IRental rental) { Transaction transaction = new Transaction(); //transaction.amount // transaction.payee //transaction.payment_options. return(default(IPaymentResponse)); }
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); }
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); }
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); }
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); }
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"); } }
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); }
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(); } }
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); }
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); }
public RefuelOnReturnDecorator(IRental rentalInstance, float price) : base(rentalInstance) { refuelPrice = price; }
public RentalFinalization FinalizeRental(IRental rental, IRentalOperator rentalOperator) { return(rentalOperator.FinalizeRental(this, rental)); }
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; }
public GameApplication(IGame game, IRental rental, IMapper mapper) { _game = game; _rental = rental; _mapper = mapper; }
public RentalApplication(IRental rental, IMapper mapper) { _rental = rental; _mapper = mapper; }
public CarRentalDecorator(IRental instance) { rental = instance; }
public void AddRental(IRental rental) { this.Rentals.Add(rental); }
public void AddRental(IRental rental) { _rentals.Add(rental); }