Пример #1
0
        public void GetAllRentalsShouldContainTwoRentals()
        {
            //Arrange

            var testHelper = new TestHelper();
            var testData   = testHelper.CreateEquipmentList();

            RentalPlan rp = new RentalPlan();

            rp.Id       = 1;
            rp.Duration = 8;
            rp.Discount = 0;

            Rental rental = new Rental();

            rental.CustomerName        = "Johan Eriksson";
            rental.CustomerPhoneNumber = "0705556677";
            rental.StartTime           = DateTime.Now;
            rental.EquipmentId         = testData[0].Id;
            rental.RentalPlanId        = rp.Id;

            Rental rental2 = new Rental();

            rental2.CustomerName        = "Johan Eriksson";
            rental2.CustomerPhoneNumber = "0705556677";
            rental2.StartTime           = DateTime.Now;
            rental2.EquipmentId         = testData[1].Id;
            rental2.RentalPlanId        = rp.Id;

            IRentalRepository rentalRepository = Substitute.For <IRentalRepository>();

            rentalRepository.GetAllRentals().Returns(new List <Rental> {
                rental, rental2
            });

            IUnitOfWork uow = Substitute.For <IUnitOfWork>();

            uow.RentalRepository.Returns(rentalRepository);

            RentalService rs = new RentalService(uow);

            //Act
            var rentals = rs.GetAllRentals();

            //Assert
            rentals.Should().HaveCount(2);
        }
Пример #2
0
 public IActionResult GetAllRentals([FromQuery] bool containUnavailable)
 {
     return(Ok(_rentalService.GetAllRentals(containUnavailable)));
 }
Пример #3
0
        // GET: api/Company
        public IEnumerable <RentalDataModel> Get()
        {
            var service = new RentalService();

            return(service.GetAllRentals());
        }