public async void CreateLibro() { // Configure EF to be used in memory for testing purposes var options = new DbContextOptionsBuilder <LibreriaContext>() .UseInMemoryDatabase("LibrosDB") .Options; var context = new LibreriaContext(options); var rabbitEventBus = new Mock <IRabbitEventBus>(); rabbitEventBus.Setup(x => x.Publish(new EmailEventQueue("*****@*****.**", "test title", "test content"))); var request = new NewLibroCommand { Titulo = "Libro titulo", AutorLibro = Guid.Empty, FechaPublicacion = DateTime.Now }; var handler = new NewLibroCommandHandler(context, rabbitEventBus.Object); var result = await handler.Handle(request, new System.Threading.CancellationToken()); Assert.True(result != null); }
public async Task <ActionResult <Unit> > Create(NewLibroCommand data) { return(await _mediator.Send(data)); }