Exemplo n.º 1
0
        public async Task TestCalculation2HoursAnd30Mintues()
        {
            using (DataAccess dal = new DataAccess())
            {
                dal.InitDatabase();
                Customer c = new Customer
                {
                    Birthday  = System.DateTime.Now,
                    Firstname = "Max",
                    Lastname  = "Mustermann",
                    Street    = "MusterStreet",
                    Town      = "MusterTown",
                    ZipCode   = "1234"
                };
                int customerId = await dal.AddCustomer(c);

                Assert.True(customerId >= 0);

                Bike b = new Bike
                {
                    Brand                      = "Testbrand",
                    PurchaseDate               = System.DateTime.Now,
                    RentalPriceFirstHour       = 10,
                    RentalPriceAdditionalHours = 20,
                    BikeCategory               = BikeCategory.Standard
                };
                int bikeId = await dal.AddBike(b);

                Assert.True(bikeId >= 0);

                Rental rental = await dal.StartRental(customerId, bikeId);

                rental = await dal.StopRental(rental.RentalId, rental.RentalBegin.AddMinutes(150));

                Assert.True(rental.TotalAmount == (b.RentalPriceFirstHour + 2 * b.RentalPriceAdditionalHours));
            }
        }