Beispiel #1
0
        public void CreateRentalWithRentedEquipmentShouldFail()
        {
            //Arrange
            IRentalRepository rentalRepository = Substitute.For <IRentalRepository>();

            rentalRepository.GetRentalByEquipmentId(2).Returns(new Rental());

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

            uow.RentalRepository.Returns(rentalRepository);

            RentalService rs = new RentalService(uow);

            //Act
            var result = rs.CreateRental(new Rental {
                EquipmentId = 2
            });

            //Assert
            result.Should().Be(CreateRentalResult.EquipmentIsAlreadyRented);
        }
Beispiel #2
0
        public void CreateRentalWillCreateRentalObject()
        {
            //Arrange
            var testHelper = new TestHelper();
            var testData   = testHelper.CreateEquipmentList();

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


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

            uow.RentalRepository.Returns(rentalRepository);

            RentalService rs = new RentalService(uow);

            Rental rental = new Rental();

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

            RentalPlan rp = new RentalPlan();

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

            rental.RentalPlanId = rp.Id;

            //Act
            rs.CreateRental(rental);

            //Assert
            rentalRepository.Received().CreateRental(rental);
        }