public void MakeNewReservationReturnsCorrectResult(BookingViewModel sut)
        {
            MakeReservationCommand result = sut.MakeNewReservation();
            var expected = sut.AsSource().OfLikeness <MakeReservationCommand>().Without(d => d.Id);

            expected.ShouldEqual(result);
        }
        public void RejectReturnsCorrectResult(MakeReservationCommand sut)
        {
            var expected = sut.AsSource().OfLikeness <ReservationRejectedEvent>();
            ReservationRejectedEvent result = sut.Reject();

            expected.ShouldEqual(result);
        }
Пример #3
0
        public async Task <ActionResult <Reservation> > MakeReservationAsync([FromBody] MakeReservationCommand makeReservationCommand)
        {
            _logger.LogInformation(
                "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
                makeReservationCommand.GetType(),
                nameof(makeReservationCommand.EmployeeId),
                makeReservationCommand.EmployeeId,
                makeReservationCommand);

            return(await _mediator.Send(makeReservationCommand));
        }
Пример #4
0
        private static void Main(string[] args)
        {
            Console.WriteLine("CQRS - sample ");
            Console.ReadLine();

            // -- create a new make a reservation command
            var command = new MakeReservationCommand(Guid.NewGuid(), "Anjam Tahir", 4, DateTime.Now.AddDays(2),
                                                     "01733112233");

            IRepository<ReservationItem> repository = new Repository();

            // -- tell associated hander to handle the command
            var commandHander = new MakeReservationCommandHander(repository);
            commandHander.Handle(command);
        }
        public void ConsumePublishesEvent([Frozen] Mock <IChannel> channelMock, RejectingReservationConsumer sut, MakeReservationCommand cmd)
        {
            var expectedEvent = cmd.Reject().AsSource().OfLikeness <ReservationRejectedEvent>();

            sut.Consume(cmd);
            channelMock.Verify(c => c.Send(expectedEvent));
        }
Пример #6
0
 public Guid MakeReservation(MakeReservationCommand command)
 {
     throw new NotImplementedException();
 }
 public void IdIsStable(MakeReservationCommand sut)
 {
     Assert.Equal(sut.Id, sut.Id);
 }
 public void IdIsUnique(MakeReservationCommand sut, MakeReservationCommand other)
 {
     Assert.NotEqual <Guid>(other.Id, sut.Id);
 }
 public void QuantityIsCorrect([Frozen] int quantity, MakeReservationCommand sut)
 {
     Assert.Equal <int>(quantity, sut.Quantity);
 }
 public void NameIsCorrect([Frozen] string name, MakeReservationCommand sut)
 {
     Assert.Equal <string>(name, sut.Name);
 }
 public void EmailIsCorrect([Frozen] string email, MakeReservationCommand sut)
 {
     Assert.Equal <string>(email, sut.Email);
 }
 public void DateIsCorrect([Frozen] DateTime date, MakeReservationCommand sut)
 {
     Assert.Equal <DateTime>(date, sut.Date);
 }
Пример #13
0
        public async Task <IActionResult> CreateReservation(MakeReservationCommand cmd)
        {
            var reservationId = await _commandDispatcher.SendAsync(cmd);

            return(Created($"hotels/{cmd.HotelId}/rooms/{cmd.RoomId}/reservations/{reservationId}", new { cmd.HotelId, cmd.RoomId, reservationId }));
        }
 public void ConsumePublishesEvent([Frozen]Mock<IChannel> channelMock, AcceptingReservationConsumer sut, MakeReservationCommand cmd)
 {
     var expectedEvent = cmd.Accept().AsSource().OfLikeness<ReservationAcceptedEvent>();
     sut.Consume(cmd);
     channelMock.Verify(c => c.Send(expectedEvent));
 }
Пример #15
0
        public void ConsumeAddsReservationToRepository([Frozen] Mock <IReservationRepository> repositoryMock, ReservationWriter sut, MakeReservationCommand cmd)
        {
            var expectedReseveration = cmd.Accept().AsSource().OfLikeness <ReservationAcceptedEvent>();

            sut.Consume(cmd);
            repositoryMock.Verify(r => r.AddReservation(It.Is <ReservationAcceptedEvent>(e => expectedReseveration.Equals(e))));
        }
Пример #16
0
 Book([FromBody] MakeReservationCommand query)
 => await this.Send(query);