public void GetAllMenus() { var options = new DbContextOptionsBuilder <CookDbContext>() .UseInMemoryDatabase(databaseName: "CookTest") .Options; // Use a separate instance of the context to verify correct data was saved to database var context = new CookDbContext(options); var service = new EFMenuService(context); var meals = service.GetMenus(); Assert.Equal(meals.Count, context.Menu.Count()); }
public void GetMenuById() { var options = new DbContextOptionsBuilder <CookDbContext>() .UseInMemoryDatabase(databaseName: "CookTest") .Options; // Use a separate instance of the context to verify correct data was saved to database var context = new CookDbContext(options); var service = new EFMenuService(context); Menu menu = new Menu(); var menus = service.GetMenus(); foreach (var item in menus) { if (item.Week == menu.Week) { menu = item; } } bool mealBool = service.Menu.Where(m => m.Week == 12) != null ? true : false; Assert.True(mealBool); }