public void StartEtlProcess_InsertsCorrectResults() { // arrange: run the ETL process once _etl.StartEtlProcess(_context); // assert: correct amount of records inserted based on what it is in test files int expectedCount = 7793; Assert.Equal(expectedCount, _context.Ingredient.Count()); int expectedFoodGroupCount = 25; Assert.Equal(expectedFoodGroupCount, _context.Category.Count()); }
/// <summary> /// Inserts a subset (250 records) of Ingredient test data into <paramref name="context"/> using the USDA Food Composition ETL process. /// </summary> /// <param name="context"></param> internal static void InitializeIngredientsFromUSDA(PantryPlannerContext context) { // load ingredient data into in-memory database USDAFoodCompositionDbETL etl = new USDAFoodCompositionDbETL(FoodCompositionETLUnitTest.FoodCompositionFolderLocation); etl.StartEtlProcess(context, 250); // mark a few ingredients as created by TestUser for test purposes for (int i = 0; i < 5; i++) { Ingredient ingredient = context.Ingredient.Skip(i).FirstOrDefault(); ingredient.AddedByUserId = TestUserID; context.Entry(ingredient).State = EntityState.Modified; } context.SaveChanges(); }