public void DetectsDetails_IfIngredientContainsComponentDetails_IndicatedByColon() { var test = "zucchini, tomato.\nMilk: water, calcium."; var result = _parser.Parse(test, new List <IngredientsParser.ParsedAnnotation>()); Assert.Equal(3, result.Ingredients.Count); Assert.Equal("zucchini", result.Ingredients[0].Name); Assert.Equal("tomato", result.Ingredients[1].Name); Assert.Equal("milk", result.Ingredients[2].Name); Assert.Equal(2, result.Ingredients[2].Ingredients.Count); Assert.Equal("water", result.Ingredients[1].Ingredients[0].Name); Assert.Equal("calcium", result.Ingredients[1].Ingredients[1].Name); }
internal void ParseIngredients() { var parser = new IngredientsParser(); List <IngredientsParser.ParsedAnnotation> annotations = new List <IngredientsParser.ParsedAnnotation>(); var _parsedIngredients = parser.Parse(_currentProduct.DisplayIngredients, annotations); var translator = new IngredientLanguageNames(_repo); var nutrientTranslator = new NutrientLanguageNames(_repo); var euNumbers = new EUAdditiveLanguageNames(_repo); foreach (var parsedIngredient in _parsedIngredients.Ingredients) { Product.Ingredients.Add(new IngredientViewModel(parsedIngredient, Product)); } var additives = DetectEUNumbers(_parsedIngredients.Ingredients, euNumbers).OrderBy(w => w.EUNumber); foreach (var additive in additives) { Product.EUAdditives.Add(new EUAdditiveViewModel(additive.EUNumber, additive.DisplayName)); } var allergens = CollectAllergens(_parsedIngredients.Ingredients); foreach (var allergen in allergens) { Product.Allergens.Add(new AllergenViewModel(allergen.Name, allergen.DisplayName)); } ProcessNutrients(); Product.Translate(); }