public async Task ForCreateTentativeReservationCommand_ShouldAddNewReservation()
        {
            // Given
            var repository      = new FakeRepository <Reservation>();
            var numberGenerator = new FakeReservationNumberGenerator();

            var commandHandler = new ReservationCommandHandler(
                repository,
                numberGenerator
                );

            var command = CreateTentativeReservation.Create(Guid.NewGuid(), Guid.NewGuid());

            // When
            await commandHandler.Handle(command, CancellationToken.None);

            //Then
            repository.Aggregates.Should().HaveCount(1);

            var reservation = repository.Aggregates.Values.Single();

            reservation
            .IsTentativeReservationWith(
                command.ReservationId,
                numberGenerator.LastGeneratedNumber,
                command.SeatId
                )
            .HasTentativeReservationCreatedEventWith(
                command.ReservationId,
                numberGenerator.LastGeneratedNumber,
                command.SeatId
                );
        }
    public void ForValidParams_ShouldCreateReservationWithTentativeStatus()
    {
        // Given
        var reservationId   = Guid.NewGuid();
        var numberGenerator = new FakeReservationNumberGenerator();
        var seatId          = Guid.NewGuid();

        // When
        var reservation = Reservation.CreateTentative(
            reservationId,
            numberGenerator,
            seatId
            );

        // Then
        numberGenerator.LastGeneratedNumber.Should().NotBeNull();

        reservation
        .IsTentativeReservationWith(
            reservationId,
            numberGenerator.LastGeneratedNumber,
            seatId
            )
        .HasTentativeReservationCreatedEventWith(
            reservationId,
            numberGenerator.LastGeneratedNumber,
            seatId
            );
    }
Exemplo n.º 3
0
        public ReservationBuilder Tentative()
        {
            var reservationId   = Guid.NewGuid();
            var numberGenerator = new FakeReservationNumberGenerator();
            var seatId          = Guid.NewGuid();

            // When
            var reservation = Reservation.CreateTentative(
                reservationId,
                numberGenerator,
                seatId
                );

            build = () => reservation;

            return(this);
        }