public PizzaOrderStrategy(List <IProduct> products, IngredientMap ingredientMap, SizeMap sizeMap, IOrderStrategy nextStrategy) { _products = products; _ingredientMap = ingredientMap; _sizeMap = sizeMap; _nextStrategy = nextStrategy; }
public void GivenExistingAlternativeIngredientNameNotAvailableAtLocation_WhenAskingToMap_ThenItShouldThrow() { // arrange const string name = "Crispy Ham"; IngredientMap ingredientMap = new IngredientMap(); // act Action action = () => ingredientMap.DomainIngredient(name, new Pizza(), new BedrockLocation()); // assert action.Should().Throw <Exception>(); }
public void GivenExistingDefaultIngredientNameNotAvailableAtLocation_WhenAskingToMap_ThenItShouldThrow() { // arrange const string name = "Bacon"; IngredientMap ingredientMap = new IngredientMap(); // act Action action = () => ingredientMap.DomainIngredient(name, new Pizza(), new SpringfieldLocation()); // assert action.Should().Throw <Exception>(); }
public void GivenExistingIngredientName_WhenAskingToMap_ThenItShouldReturnCorrectIngredient() { // arrange const string name = "Olives"; IngredientMap ingredientMap = new IngredientMap(); // act IIngredient mappedIngredient = ingredientMap.DomainIngredient(name, new Pizza(), new BedrockLocation()); // assert mappedIngredient.Name().ToString().Should().BeEquivalentTo(new OlivesName()); }
public void GivenNonExistentIngredientName_WhenAskingToMap_ThenItShouldThrow() { // arrange const string name = "Dammit, Bobby!"; IngredientMap ingredientMap = new IngredientMap(); // act Action action = () => ingredientMap.DomainIngredient(name, new Pizza(), new BedrockLocation()); // assert action.Should().Throw <Exception>(); }
public void GivenExistingAlternativeIngredientName_WhenAskingToMap_ThenItShouldReturnCorrectIngredient() { // arrange const string name = "Crispy Ham"; IngredientMap ingredientMap = new IngredientMap(); // act IIngredient mappedIngredient = ingredientMap.DomainIngredient(name, new Pizza(), new SpringfieldLocation()); // assert mappedIngredient.Name().ToString().Should().BeEquivalentTo(new CrispyHamName()); mappedIngredient.GetType().Name.Should().Be(nameof(CrispyHam)); }
private void PopulateInitialMaps() { //< Instantiate the 'maps' this.AllergenMap = new AllergenMap(); this.IngredientMap = new IngredientMap(); //< Iterate over each available Recipe foreach (var recipe in Recipes) { //< Iterate over each available allergen foreach (var allergen in recipe.Allergens) { //< Iterate over each ingredient foreach (var ingredient in recipe.Ingredients) { if (!IngredientMap.ContainsKey(ingredient)) { IngredientMap.Add(ingredient, new AllergenMap()); } if (!IngredientMap[ingredient].ContainsKey(allergen)) { IngredientMap[ingredient].Add(allergen, 0); } IngredientMap[ingredient][allergen]++; } //< Populate the allergen map (count of times an allergen is encountered across recipes) if (!AllergenMap.ContainsKey(allergen)) { AllergenMap.Add(allergen, 0); } AllergenMap[allergen]++; } } }