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)); }
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 RequestAsync_Reservation_Insert_Valid() { var key = FakeHelper.Key; var book = BookMock.Get(key); var copy = CopyMock.Get(key); MockRepository.Add(book); MockRepository.Add(copy); var message = ReservationMessageMock.Get(key); var dto = RequestAsync(message); dto.Should().NotBeNull(); var entity = Db.Reservations.FirstOrDefault(x => x.Number == Fake.GetReservationNumber(key)); var expected = ReservationMock.GetByReservation(key); expected.Id = entity.Id; expected.Member.Id = entity.Member.Id; expected.Loans[0].Id = entity.Loans[0].Id; entity.Should().BeEquivalentToEntity(expected); var dtoExpected = ReservationDtoMessageMock.Get(key); dtoExpected.ReservationId = entity.Id; dto.Should().BeEquivalentToMessage(dtoExpected); //var profillingExpected = ProfilingEntityMock.Get("", ""); }