Beispiel #1
0
        public void Then_Maps_Matching_Fields(ReservationCreatedEvent source)
        {
            ReservationCreatedNotificationEvent result = source;

            result.Should().BeEquivalentTo(source, options =>
                                           options.ExcludingMissingMembers());
        }
Beispiel #2
0
        public async Task Then_Update_Index_Action_Executed(
            int courseLevel,
            ReservationCreatedEvent createdEvent)
        {
            //Arrange
            createdEvent.CourseLevel = courseLevel.ToString();

            var addNonLevyReservationToReservationsIndexAction =
                new Mock <IAddNonLevyReservationToReservationsIndexAction>();

            var notifyEmployerOfReservationEventAction = new Mock <INotifyEmployerOfReservationEventAction>();

            var handler = new ReservationCreatedHandler(addNonLevyReservationToReservationsIndexAction.Object,
                                                        notifyEmployerOfReservationEventAction.Object);

            //Act
            await HandleReservationCreatedEvent.Run(
                createdEvent,
                Mock.Of <ILogger <ReservationCreatedEvent> >(),
                handler);

            //Assert
            addNonLevyReservationToReservationsIndexAction.Verify(s => s.Execute(It.Is <Reservation>(index =>
                                                                                                     index.Id == createdEvent.Id)), Times.Once);
        }
Beispiel #3
0
        public Reservation(CreateReservationRequest createReservationRequest)
        {
            var streamId = $"reservation-{createReservationRequest.SessionId}-{createReservationRequest.MemberId}";
            var reservationCreatedEvent = new ReservationCreatedEvent
            {
                StreamId        = streamId,
                ReservationId   = streamId,
                SessionId       = createReservationRequest.SessionId,
                MemberId        = createReservationRequest.MemberId,
                SessionLocation = createReservationRequest.SessionLocation,
            };

            _AddEvent(reservationCreatedEvent);
        }
Beispiel #4
0
        public void Then_Maps_Matching_Fields(
            int courseLevel,
            ReservationCreatedEvent source)
        {
            source.CourseLevel = courseLevel.ToString();

            Reservation result = source;

            result.Should().BeEquivalentTo(source, options =>
                                           options.ExcludingMissingMembers()
                                           .Excluding(ev => ev.Id)
                                           .Excluding(ev => ev.CourseLevel));
            result.Status.Should().Be(ReservationStatus.Pending);
        }
Beispiel #5
0
        public static async Task Run(
            [NServiceBusTrigger(EndPoint = QueueNames.ReservationCreated)] ReservationCreatedEvent message,
            [Inject] ILogger <ReservationCreatedEvent> log,
            [Inject] IReservationCreatedHandler handler)
        {
            log.LogInformation($"Reservation Created function executing at: [{DateTime.UtcNow}] UTC, event with ID: [{message.Id}].");

            if (message.Id != null && message.Id != Guid.Empty)
            {
                await handler.Handle(message);

                log.LogInformation($"Reservation Created function finished at: [{DateTime.UtcNow}] UTC, event with ID: [{message.Id}] has been handled.");
            }
            else
            {
                log.LogInformation($"No reservation created, no reservation ReservationId provided");
            }
        }
        public async Task And_Create_Notification_Then_Sends_Message_With_Create_Template(
            ReservationCreatedEvent createdEvent,
            Dictionary <string, string> tokens,
            [ArrangeUsers] List <UserDetails> users,
            [Frozen] Mock <INotificationTokenBuilder> mockTokenBuilder,
            [Frozen] Mock <IAccountsService> mockAccountsService,
            [Frozen] Mock <INotificationsService> mockNotificationsService,
            NotifyEmployerOfReservationEventAction action)
        {
            mockAccountsService
            .Setup(service => service.GetAccountUsers(createdEvent.AccountId))
            .ReturnsAsync(users);
            mockTokenBuilder
            .Setup(builder => builder.BuildTokens(It.IsAny <INotificationEvent>()))
            .ReturnsAsync(tokens);

            await action.Execute <ReservationCreatedNotificationEvent>(createdEvent);

            mockNotificationsService.Verify(service =>
                                            service.SendNewReservationMessage(It.Is <NotificationMessage>(message =>
                                                                                                          message.TemplateId == TemplateIds.ReservationCreated))
                                            , Times.Exactly(users.Count));
        }
Beispiel #7
0
 private ISystemEvent ReservationCreatedHandler(ReservationCreatedEvent f)
 {
     return(new OrderCreatedEvent(f.AggregateId));
 }
Beispiel #8
0
 private void _Created(ReservationCreatedEvent @event)
 {
     Id        = @event.ReservationId;
     SessionId = @event.SessionId;
     MemberId  = @event.MemberId;
 }
Beispiel #9
0
        public async Task Handle(ReservationCreatedEvent createdEvent)
        {
            await _notifyAction.Execute <ReservationCreatedNotificationEvent>(createdEvent);

            await _addNonLevyReservationToReservationsIndexAction.Execute(createdEvent);
        }