public ActionResult <IEnumerable <Star> > GetAll() { try { return(Ok(_service.GetAll())); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
public async Task TestGetAllStars() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("Stars"); var starRepository = new EfDeletableEntityRepository <Stars>(new ApplicationDbContext(options.Options)); await starRepository.AddAsync(new Stars { Name = "One" }); await starRepository.AddAsync(new Stars { Name = "Two" }); await starRepository.SaveChangesAsync(); var starsService = new StarsService(starRepository); AutoMapperConfig.RegisterMappings(typeof(MyTestStars).Assembly); var stars = starsService.GetAll <MyTestStars>(); Assert.Equal(2, stars.Count()); }