Ejemplo n.º 1
0
        public async Task ReturnCarAsync_Valid_UpdatesReservationStateAndRentalFeePaid()
        {
            //Arrange
            var mockedReservationRepository = GetReservationRepositoryWithReservation(50, ReservationState.PickedUp);
            var bl = new BLReservation(mockedReservationRepository, null, null, mockedUnitOfWork);

            //Act
            var reservation = await bl.ReturnCarAsync(50);

            //Assert
            Assert.Equal(ReservationState.Returned, reservation.State);
            Assert.Equal(5, reservation.ClientAccount.RentalFeePaid);
        }
Ejemplo n.º 2
0
        public async Task ReturnCarAsync_Invalid_ThrowsCustomException(long reservationIdToReturn, long reservationIdInDb, ReservationState previousState, ErrorCode errorCode)
        {
            //Arrange
            var mockedReservationRepository = GetReservationRepositoryWithReservation(reservationIdInDb, previousState);
            var bl = new BLReservation(mockedReservationRepository, null, null, mockedUnitOfWork);

            //Act
            async Task act() => await bl.ReturnCarAsync(reservationIdToReturn);

            //Assert
            var exception = await Assert.ThrowsAsync <CustomException>(act);

            Assert.Equal(errorCode, exception.code);
        }