public void Handle_UpdateBookCommand_Default() { // arrange var key = MockBuilder.Key; var book = BookMock.Get(key); MockRepository.Add(book); MockRepository.Commit(); var key2 = MockBuilder.Key; var command = UpdateBookCommandMock.Get(key2); command.Title = book.Title; // act var result = Handle(command); // assert result.Should().BeTrue(); var books = MockRepository.Query <Book>().ToList(); var bookExpected = BookMock.Get(key2); bookExpected.Title = book.Title; books.Should().BeEquivalentToEntity(MockBuilder.List(bookExpected)); }
public void Handle_ExpireReservationCommand_Default() { // arrange var key = MockBuilder.Key; var reservation = ReservationMock.Get(key); MockRepository.Add(reservation); MockRepository.Commit(); var command = ExpireReservationCommandMock.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); reservationExpected.Status = StatusReservation.Expired; reservations.Should().BeEquivalentToEntity(MockBuilder.List(reservationExpected)); var publishReservationEventCommands = Bus.GetAllSent <PublishReservationEventCommand>(ContextNames.Queue.Library); var publishReservationEventCommandExpected = PublishReservationEventCommandMock.Get(key); publishReservationEventCommands.Should().BeEquivalentToMessage(MockBuilder.List(publishReservationEventCommandExpected)); }
public void Handle_PurchaseBookCommand_Default() { // arrange var key = MockBuilder.Key; var command = PurchaseBookCommandMock.Get(key); // act var result = Handle(command); // assert result.Should().BeTrue(); var orders = MockRepository.Query <Order>() .Include(x => x.Items) .Include(x => x.Customer) .ToList(); var orderExpected = OrderMock.Get(key); orders.Should().BeEquivalentToEntity(MockBuilder.List(orderExpected)); var publishShippingEventCommands = Bus.GetAllSent <PublishShippingEventCommand>(ContextNames.Queue.Bookstore); var publishShippingEventCommandExpected = PublishShippingEventCommandMock.Get(key); publishShippingEventCommandExpected.OrderId = orders[0].Id; publishShippingEventCommands.Should().BeEquivalentToMessage(MockBuilder.List(publishShippingEventCommandExpected)); var dropCopyNumberEvents = Bus.GetAllPublished <DropCopyNumberEvent>(ContextNames.Exchange.Bookstore); var dropCopyNumberEventExpected = DropCopyNumberEventMock.Get(key); dropCopyNumberEvents.Should().BeEquivalentToMessage(MockBuilder.List(dropCopyNumberEventExpected)); }
public void Handle_BookCommand_Default() { // arrange var key = MockBuilder.Key; var command = SaveBookCommandMock.Get(key); // act var result = Handle(command); // assert result.Should().BeTrue(); var books = MockRepository.Query <Domain.Entities.Book>().ToList(); var bookExpected = BookMock.Get(key); books.Should().BeEquivalentToEntity(MockBuilder.List(bookExpected)); var events = Bus.GetAllPublished <UpdateBookEvent>(ContextNames.Exchange.Book); var eventExpected = UpdateBookEventMock.Get(key); events.Should().BeEquivalentToMessage(MockBuilder.List(eventExpected)); }
public void MgaAddEntityValid() { // arrange var key = Fake.GetKey(); var model = MgaInputModelMock.Get(key); // act Add(model); // assertation var entities = MockRepository.Query <Mga>().ToList(); var entityExpected = MgaMock.Get(key); entities.Should().BeEquivalentToEntity(new List <Mga>() { entityExpected }); }
public void AdvisorAddEntityValid() { // arrange var key = Fake.GetKey(); var model = AdvisorInputModelMock.Get(key); // act Add(model); // assertation var entities = MockRepository.Query <Advisor>().ToList(); var entityExpected = AdvisorMock.Get(key); entityExpected.HealthStatus = entities[0].HealthStatus; entities.Should().BeEquivalentToEntity(new List <Advisor>() { entityExpected }); }
public void ContractEstablishTwoEntityValid() { // arrange var key = Fake.GetKey(); var carrier = CarrierMock.Get(key); MockRepository.Add(carrier); var key2 = Fake.GetKey(); var mga = MgaMock.Get(key2); MockRepository.Add(mga); MockRepository.Commit(); var model = ContractInputModelMock.Get(carrier.Id, mga.Id); // act Establish(model); // assertation var contracts = MockRepository.Query <Contract>().ToList(); var contractExpected = ContractMock.Get(carrier.Id, mga.Id); contracts.Should().BeEquivalentToEntity(new List <Contract>() { contractExpected }); }