public async void GetEventos() { // Arrange var options = new DbContextOptionsBuilder <AlpmysContext>() .UseInMemoryDatabase("GetTest") .Options; AlpmysContext context = new AlpmysContext(options); Evento e = new Evento(); e.Nome = "Evento!"; Evento e2 = new Evento(); e2.Nome = "Evento2"; context.Evento.Add(e); context.Evento.Add(e2); await context.SaveChangesAsync(); EventosController controller = new EventosController(context); // Act var result = await controller.GetEvento(); // Assert Assert.IsType <OkObjectResult>(result); Assert.Equal(2, context.Evento.Count()); }
public async void GetSpecificEvent() { // Arrange var options = new DbContextOptionsBuilder <AlpmysContext>() .UseInMemoryDatabase("UpdateEvent") .Options; AlpmysContext context = new AlpmysContext(options); EventosController controller = new EventosController(context); Evento e = new Evento(); e.Id = 5; e.Nome = "Evento!"; await controller.PostEvento(e); // Act var result = await controller.GetEvento(5); // Assert Assert.IsType <OkObjectResult>(result); }