public void Handle_ReserveBookCommandd_Default() { // arrange var key = MockBuilder.Key; var copy = CopyMock.Get(key); MockRepository.Add(copy); MockRepository.Commit(); var command = ReserveBookCommandMock.Get(key); // act var result = Handle(command); // assert result.Should().BeTrue(); var reservations = MockRepository.Query <Reservation>() .Include(x => x.Loans) .ThenInclude(x => x.Copy) .ThenInclude(x => x.Book) .Include(x => x.Member) .ToList(); var reservationExpected = ReservationMock.Get(key); reservations.Should().BeEquivalentToEntity(MockBuilder.List(reservationExpected)); var publishReservationEventCommands = Bus.GetAllSent <PublishReservationEventCommand>(ContextNames.Queue.Library); var PublishReservationEventCommandExpected = PublishReservationEventCommandMock.Get(key); PublishReservationEventCommandExpected.ReservationId = reservations[0].Id; publishReservationEventCommands.Should().BeEquivalentToMessage(MockBuilder.List(PublishReservationEventCommandExpected)); }
public void Handle_ReserveBookCommand_Member_Not_Exists() { // arrange var key = MockBuilder.Key; var copy = CopyMock.Get(key); MockRepository.Add(copy); MockRepository.Commit(); var command = ReserveBookCommandMock.Get(key); // act var result = Handle(command); // assert result.Should().BeTrue(); var members = MockRepository.Query <Member>().ToList(); var memberExpected = MemberMock.Get(key); members.Should().BeEquivalentToEntity(MockBuilder.List(memberExpected)); var reservations = MockRepository.Query <Reservation>() .Include(x => x.Loans) .ThenInclude(x => x.Copy) .ThenInclude(x => x.Book) .Include(x => x.Member) .ToList(); var reservationExpected = ReservationMock.Get(key); reservationExpected.Member = memberExpected; reservations.Should().BeEquivalentToEntity(MockBuilder.List(reservationExpected)); }