public ReservationService( ReservationApiDbContext context, IMapper mapper, ReservationNumberService reservationNumber, IConfiguration configuration) { _context = context; _mapper = mapper; _reservationNumber = reservationNumber; _configuration = configuration; }
public void ShouldMoveUpOneLetter_Test() { ////Arrange var reservationService = new ReservationNumberService(); ///Act for (int i = 0; i < 999; ++i) { reservationService.Next(); } var result = reservationService.Next(); ///Assert Assert.Equal("AAB001", result); }
public async void CreateReservation_ReservationService_Test() { ////Arrange /// var db = InitializeDatabase("CreateReservation_ReservationService_Test"); var loggerServiceMock = new Mock <ILogger <ReservationService> >(); var mapperConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }); IMapper mapper = mapperConfig.CreateMapper(); IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddJsonFile("AppSettings.json"); IConfiguration configuration = configurationBuilder.Build(); var reservationNumberService = new ReservationNumberService(); var reservationService = new ReservationService(db, mapper, reservationNumberService, configuration); ReservationRequest createReservation = new ReservationRequest { email = "*****@*****.**", creditCard = "123456789", flights = new ReservationFlightRequest[] { new ReservationFlightRequest { key = "Flight00001", passengers = new PassengersReservationDetailsRequest[] { new PassengersReservationDetailsRequest { name = "Robert Niro", bags = 3, seat = 1 }, new PassengersReservationDetailsRequest { name = "John Smith", bags = 3, seat = 2 }, new PassengersReservationDetailsRequest { name = "Seb True", bags = 3, seat = 3 } } }, new ReservationFlightRequest { key = "Flight00103", passengers = new PassengersReservationDetailsRequest[] { new PassengersReservationDetailsRequest { name = "Robert Niro", bags = 3, seat = 1 }, new PassengersReservationDetailsRequest { name = "John Smith", bags = 3, seat = 2 }, new PassengersReservationDetailsRequest { name = "Seb True", bags = 3, seat = 3 } } } } }; // Act on Test var result = await reservationService.CreateReservationAsync(createReservation); ///Asserrt Assert.Equal("AAA001", result.reservationNumber); }