public async Task <JourneysSelectionResource> SelectJourneys(List <string> journeyIds) { var journeys = new JourneysBuilder().BuildJourneys(); var bookingId = BookingId.New; var command = new SelectJourneysCommand(bookingId, journeys); await _commandBus.PublishAsync(command, CancellationToken.None); return(new JourneysSelectionResource(Url, bookingId.Value)); }
private async Task <BookingId> SelectJourney() { var journeys = new JourneysBuilder().BuildJourneys(); var bookingId = BookingId.New; var selectJourneysCommand = new RestAirline.Booking.Commands.Journey.SelectJourneysCommand(bookingId, journeys); //Act await CommandBus.PublishAsync(selectJourneysCommand, CancellationToken.None); return(bookingId); }
public async Task <JourneysSelectedResource> SelectJourneys(SelectJourneysCommand selectJourneysCommand) { //Will integrate journey availability micro-service before select journey, passenger query journey availability micro-service in UI //Get journey from journey availability micro-service var journeys = new JourneysBuilder().BuildJourneys(); var bookingId = BookingId.New; var command = new Booking.Commands.Journey.SelectJourneysCommand(bookingId, journeys); await _commandBus.PublishAsync(command, CancellationToken.None); return(new JourneysSelectedResource(Url, bookingId.Value)); }
public async Task <BookingResource> SelectJourneys(List <string> journeyIds) { var journeys = new JourneysBuilder().BuildJourneys(); var bookingId = BookingId.New; var command = new SelectJourneysCommand(bookingId, journeys); await _commandBus.PublishAsync(command, CancellationToken.None); var booking = await _readStore.GetAsync(bookingId.Value, CancellationToken.None); return(new BookingResource(booking.ReadModel)); }
public async Task WhenSendSelectJourneysCommandShouldAddJourneys() { //Arrange var journeys = new JourneysBuilder().BuildJourneys(); var selectJourneysCommand = new SelectJourneysCommand(_bookingId, journeys); //Act await _commandBus.PublishAsync(selectJourneysCommand, CancellationToken.None); //Assert var booking = await _aggregateStore.LoadAsync <Booking, BookingId>(_bookingId, CancellationToken.None); booking.Journeys.Should().NotBeEmpty(); }
public async Task ShouldGetDepartureStation() { //Arrange var journeys = new JourneysBuilder().BuildJourneys(); var selectJourneysCommand = new SelectJourneysCommand(BookingId.New, journeys); await CommandBus.PublishAsync(selectJourneysCommand, CancellationToken.None); //Act var query = new GetDepartureStationsQuery(DateTime.Today, DateTime.Today.AddDays(3)); var stations = await _queryHandler.ExecuteQueryAsync(query, CancellationToken.None); //Assert stations.Should().NotBeEmpty(); }
public async Task WhenSendSelectJourneysCommandShouldAddJourneysInReadModel() { //Arrange var journeys = new JourneysBuilder().BuildJourneys(); var selectJourneysCommand = new SelectJourneysCommand(_bookingId, journeys); //Act await CommandBus.PublishAsync(selectJourneysCommand, CancellationToken.None); //Assert var bookings = await _bookingReadModel.FindAsync(rm => rm.Id == _bookingId, CancellationToken.None); var booking = bookings.First(); booking.Journeys.Should().NotBeEmpty(); }
public void WhenDepartureDateLessThenNowShouldReturnFalse() { //Arrange var spec = JourneyValidationSpecification.Create(); var journeys = new JourneysBuilder().BuildJourneys(); journeys.ForEach(x => x.DepartureDate = DateTime.Today.AddDays(-1)); //Act var isSatisfy = spec.IsSatisfiedBy(journeys); var why = spec.WhyIsNotSatisfiedBy(journeys); //Assert isSatisfy.Should().BeFalse(); why.Should().HaveCount(1); }
public async Task WhenSendSelectJourneysCommandTwiceShouldGetTwoJourneysInReadModel() { //Arrange var journeys = new JourneysBuilder().BuildJourneys(); var selectJourneysCommand1 = new SelectJourneysCommand(BookingId.New, journeys); var selectJourneysCommand2 = new SelectJourneysCommand(BookingId.New, journeys); //Act await CommandBus.PublishAsync(selectJourneysCommand1, CancellationToken.None); await CommandBus.PublishAsync(selectJourneysCommand2, CancellationToken.None); //Assert var readModels = await _stationsReadModel.FindAsync(rm => true, CancellationToken.None); var stations = readModels.SelectMany(x => x.Items).Where(x => x.ArriveStation == "SYD"); stations.Should().HaveCount(2); }