Example #1
0
        public void ReservationRequestAcceptedHandler(AcceptReservationRequest command)
        {
            if (tableAvailabilityService.CheckAvailability(this.TableIds, this.StartDate, this.EndDate))
            {
                Accepted = true;
                var reservationAcceptedEvent = new ReservationRequestAccepted();
                eventDispatcher.DispatchReservationRequestAcceptedEvent(reservationAcceptedEvent);
                return;
            }


            Accepted = false;
            var reservationDeniedEvent = new ReservationRequestDenied();

            eventDispatcher.DispatchReservationRequestDeniedEvent(reservationDeniedEvent);
        }
Example #2
0
        public void WhenReservationRerquestAcceptedThenEmitsReservationAccepted()
        {
            // Given
            Mock <IEventDispatcher>                eventDispatcherMock         = new Mock <IEventDispatcher>();
            Mock <ITableAvailabilityService>       tableAvailabilityService    = new Mock <ITableAvailabilityService>();
            Mock <IRestaurantConfigurationService> restaurantConfigurationMock = new Mock <IRestaurantConfigurationService>();

            tableAvailabilityService.Setup(
                x => x.CheckAvailability(It.IsAny <List <int> >(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(true);
            var reservationRequest       = new ReservationRequest(eventDispatcherMock.Object, tableAvailabilityService.Object, restaurantConfigurationMock.Object);
            var acceptReservationRequest = new AcceptReservationRequest();

            // When
            reservationRequest.ReservationRequestAcceptedHandler(acceptReservationRequest);

            // Then
            eventDispatcherMock.Verify(x => x.DispatchReservationRequestAcceptedEvent(It.IsAny <ReservationRequestAccepted>()), Times.Once);
        }
Example #3
0
        public void WhenReservationRerquestAcceptedAndTableAvailableThenAcceptedIsTrue()
        {
            //Given
            Mock <IEventDispatcher>                eventDispatcherMock         = new Mock <IEventDispatcher>();
            Mock <ITableAvailabilityService>       tableAvailabilityService    = new Mock <ITableAvailabilityService>();
            Mock <IRestaurantConfigurationService> restaurantConfigurationMock = new Mock <IRestaurantConfigurationService>();

            tableAvailabilityService.Setup(
                x => x.CheckAvailability(It.IsAny <List <int> >(), It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(true);
            var reservationRequest       = new ReservationRequest(eventDispatcherMock.Object, tableAvailabilityService.Object, restaurantConfigurationMock.Object);
            var acceptReservationRequest = new AcceptReservationRequest();

            //When
            reservationRequest.ReservationRequestAcceptedHandler(acceptReservationRequest);

            //Then
            Assert.IsTrue(reservationRequest.Accepted);
        }