public override Task Execute() { var journeys = _journeys ?? new JourneysBuilder().BuildJourneys(); BookingId = BookingId ?? BookingId.New; var command = new SelectJourneysCommand(BookingId, journeys); return(CommandBus.PublishAsync(command, CancellationToken.None)); }
public async Task ShouldSelectJourney() { //Arrange var command = new SelectJourneysCommand(); //Act var resource = await _apiTestClient.Post <SelectJourneysCommand, JourneysSelectedResource>("booking/journeys", command); //Assert resource.ResourceLinks.Should().NotBeNull(); resource.ResourceCommands.Should().NotBeNull(); }
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 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 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); }
public Commands(IUrlHelper urlHelper) { _urlHelper = urlHelper; SelectJourneysCommand = new SelectJourneysCommand(_urlHelper); }