public void CreateSampleData(DbContextOptions <MarketPlaceBackendContext> options) { using (var _context = new MarketPlaceBackendContext(options)) { var ApplicationsToAdd = new List <Application> { new Application() { Id = "abcd-efgh", Name = "Github", Info = "Github Integration", AppUrl = "www.github.com", Developer = "Mr. XYZ", LogoUrl = "www.logo.com" }, new Application() { Id = "wxyz-abcd", Name = "Google Drive", Info = "Google Drive Integration", AppUrl = "www.googledrive.com", Developer = "Mr. ABC", LogoUrl = "www.glogo.com" } }; _context.Application.AddRange(ApplicationsToAdd); _context.SaveChanges(); } }
public ApplicationsController GetController() { var optionsBuilder = new DbContextOptionsBuilder <MarketPlaceBackendContext>(); optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); var marketPlaceContext = new MarketPlaceBackendContext(optionsBuilder.Options); CreateSampleData(optionsBuilder.Options); var _service = new ApplicationService(marketPlaceContext); return(new ApplicationsController(_service)); }
public ApplicationService(MarketPlaceBackendContext context) { _context = context; }