public void GetIngredients_GetAllIngredientsCorrectly() { //Arrange Recipe testRecipe = new Recipe("cookies", "foo bar", 1); testRecipe.Save(); Ingredient newIngredient1 = new Ingredient("Egg"); newIngredient1.Save(); Ingredient newIngredient2 = new Ingredient("Milk"); newIngredient2.Save(); List <Ingredient> expectedIngredients = new List <Ingredient> { newIngredient1, newIngredient2 }; testRecipe.AddIngredient(newIngredient1); testRecipe.AddIngredient(newIngredient2); //Act List <Ingredient> ingredients = testRecipe.GetIngredients(); //Assert CollectionAssert.AreEqual(expectedIngredients, ingredients); }
public void AddIngredient_AddsIngredientToRecipe_IngredientList() { //Arrange Ingredient testIngredient1 = new Ingredient("Olive Oil"); testIngredient1.Save(); Ingredient testIngredient2 = new Ingredient("Red Peppers"); testIngredient2.Save(); Recipe firstRecipe = new Recipe("Roasted Artichokes", "5", "cook"); firstRecipe.Save(); List <Ingredient> testList = new List <Ingredient> { testIngredient1, testIngredient2 }; //Act firstRecipe.AddIngredient(testIngredient1); firstRecipe.AddIngredient(testIngredient2); List <Ingredient> result = firstRecipe.GetIngredients(); //Assert Assert.AreEqual(testList.Count, result.Count); }
public FakeRecipeRepository() { if (recipes == null) { recipes = new List <Recipe>(); Ingredient lettuce = new Ingredient { IngredientName = "lettuce", Quantity = 1, Measure = "cup" }; Ingredient tomatoes = new Ingredient { IngredientName = "tomatoes", Quantity = .5, Measure = "cup" }; Recipe salad = new Recipe { Name = "salad", Servings = 2, Instructions = "Toss ingredients.", Date = DateTime.Now, Rating = 5, ImgUrl = "/images/lettuce-tomato-salad.jpg" }; salad.AddIngredient(lettuce); salad.AddIngredient(tomatoes); AddRecipe(salad); } }
public RecipesVM() { this.Recipes = new ObservableCollection <SearchResultRecipeVM>(); #if DEBUG Recipe newRecipe = new Recipe("The kale dish", ""); newRecipe.CookTime = "25 min"; newRecipe.AddIngredient(new FoodItem("Kale", "")); newRecipe.AddIngredient(new FoodItem("Potatoes", "")); newRecipe.AddIngredient(new FoodItem("Bacon", "")); Recipes.Add(new SearchResultRecipeVM(newRecipe)); newRecipe = new Recipe("Lamb Biryani", ""); newRecipe.CookTime = "45 min"; newRecipe.AddIngredient(new FoodItem("Lamb", "")); newRecipe.AddIngredient(new FoodItem("Potatoes", "")); newRecipe.AddIngredient(new FoodItem("Peas", "")); newRecipe.AddIngredient(new FoodItem("Spices", "")); newRecipe.AddIngredient(new FoodItem("Rice", "")); Recipes.Add(new SearchResultRecipeVM(newRecipe)); newRecipe = new Recipe("Mushroom risotti", ""); newRecipe.CookTime = "45 min"; newRecipe.AddIngredient(new FoodItem("Risotto rice", "")); newRecipe.AddIngredient(new FoodItem("Parmesan", "")); newRecipe.AddIngredient(new FoodItem("Spinach", "")); Recipes.Add(new SearchResultRecipeVM(newRecipe)); #endif }
public void GetIngredients_ReturnsAllIngredientRecipes_IngredientList() { //Arrange Ingredient testIngredient1 = new Ingredient("Artichoke"); testIngredient1.Save(); Ingredient testIngredient2 = new Ingredient("Red Peppers"); testIngredient2.Save(); Recipe testRecipe1 = new Recipe("Roasted Artichokes", "5", "cook"); testRecipe1.Save(); //Act testRecipe1.AddIngredient(testIngredient1); testRecipe1.AddIngredient(testIngredient2); List <Ingredient> result = testRecipe1.GetIngredients(); Console.WriteLine(result[1].GetName()); List <Ingredient> testList = new List <Ingredient> { testIngredient1, testIngredient2 }; //Assert Assert.AreEqual(testList.Count, result.Count); // CollectionAssert.AreEqual(testList, result); }
public static async Task SeedDatabaseAsync(this IServiceProvider serviceProvider) { var mongoContext = serviceProvider.GetService <MongoDbContext>(); await mongoContext.RecipesCollection.Database.DropCollectionAsync("Recipes").ConfigureAwait(false); var recipe = new Recipe("recipe1"); recipe.AddIngredient(new Ingredient("ingredient1", 10, IngredientType.AcidRegulator)); recipe.AddIngredient(new Ingredient("ingredient3", 10, IngredientType.Color)); recipe.AddIngredient(new Ingredient("ingredient4", 10, IngredientType.Emulsifier)); recipe.AddIngredient(new Ingredient("ingredient5", 10, IngredientType.AcidRegulator)); recipe.AddIngredient(new Ingredient("ingredient6", 10, IngredientType.AcidRegulator)); recipe.AddIngredient(new Ingredient("ingredient7", 10, IngredientType.AcidRegulator)); recipe.AddIngredient(new Ingredient("ingredient8", 10, IngredientType.AcidRegulator)); recipe.AddIngredient(new Ingredient("ingredient9", 10, IngredientType.AcidRegulator)); recipe.AddIngredient(new Ingredient("ingredient10", 10, IngredientType.AcidRegulator)); recipe.AddIngredient(new Ingredient("ingredient11", 10, IngredientType.AcidRegulator)); await mongoContext.RecipesCollection.InsertOneAsync(recipe).ConfigureAwait(false); var recipe2 = new Recipe("recipe2"); recipe2.AddIngredient(new Ingredient("ingredient21", 10, IngredientType.AcidRegulator)); recipe2.AddIngredient(new Ingredient("ingredient22", 10, IngredientType.Emulsifier)); recipe2.AddIngredient(new Ingredient("ingredient23", 10, IngredientType.Color)); recipe2.AddIngredient(new Ingredient("ingredient24", 10, IngredientType.Flavor)); recipe2.AddIngredient(new Ingredient("ingredient25", 10, IngredientType.AcidRegulator)); await mongoContext.RecipesCollection.InsertOneAsync(recipe2).ConfigureAwait(false); }
public async Task ItRemovesTheIngredient() { var original = new Recipe(name: nameof(ItRemovesTheIngredient)); var toDelete = original.AddIngredient(new Ingredient(Guid.NewGuid().ToString()), UnitOfMeasure.Cup, 2M); original.AddIngredient(new Ingredient(Guid.NewGuid().ToString()), UnitOfMeasure.Pint, 5M); await AppFixture.InsertAsync(original); var request = new RemoveIngredientRequest { RecipeModelKey = new ModelUpdateIdentifier(original), RecipeIngredientModelKey = new ModelUpdateIdentifier(toDelete) }; await AppFixture.SendAsync(request); var saved = await AppFixture.ExecuteDbContextAsync(async db => { return(await db.Recipes.Where(x => x.Id == original.Id).Include(x => x.RecipeIngredients) .FirstOrDefaultAsync()); }); saved.RecipeIngredients.Should().HaveCount(1); saved.RecipeIngredients[0].UnitOfMeasure.Should().Be(UnitOfMeasure.Pint); }
public override void AddRecipes() { Recipe recipe = CreateRecipe() .AddIngredient(null, "UniverseCore") .AddIngredient(null, "BerserkerSoul") .AddIngredient(null, "SnipersSoul") .AddIngredient(null, "ArchWizardsSoul") .AddIngredient(null, "ConjuristsSoul") .AddIngredient(null, "AbomEnergy", 10) .AddTile(ModContent.Find <ModTile>("Fargowiltas", "CrucibleCosmosSheet")); if (ModLoader.TryGetMod("FargowiltasSoulsDLC", out Mod fargoDLC)) { if (ModLoader.TryGetMod("ThoriumMod", out Mod thorium)) { recipe.AddIngredient(ModContent.Find <ModItem>("FargowiltasSoulsDLC", "GuardianAngelsSoul")); recipe.AddIngredient(ModContent.Find <ModItem>("FargowiltasSoulsDLC", "BardSoul")); } if (ModLoader.TryGetMod("CalamityMod", out Mod calamity)) { recipe.AddIngredient(ModContent.Find <ModItem>("FargowiltasSoulsDLC", "RogueSoul")); } if (ModLoader.TryGetMod("DBZMOD", out Mod dbz)) { recipe.AddIngredient(ModContent.Find <ModItem>("FargowiltasSoulsDLC", "KiSoul")); } } recipe.Register(); }
public void ShouldAddIngredients() { var ingredient = new Ingredient(string.Empty, string.Empty); _recipe.AddIngredient(ingredient); Assert.Contains(ingredient, _recipe.Ingredients); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.AddIngredient(ItemID.DemoniteBar, 15); recipe.AddIngredient(ItemID.Amethyst); recipe.AddTile(TileID.Anvils); recipe.Register(); }
static RecipeFactory() { var granolaBar = new Recipe(1, "Granola Bar"); granolaBar.AddIngredient(3001, 1); granolaBar.AddIngredient(3002, 1); granolaBar.AddIngredient(3003, 1); granolaBar.AddOutput(2001, 1); s_recipes.Add(granolaBar); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.createItem = this.item.Clone(); recipe.createItem.stack = 1; recipe.AddIngredient(Mod.ItemType("StorageUnit")); recipe.AddIngredient(Mod.ItemType("UpgradeDemonite")); recipe.Register(); }
public void ShouldAddIngredients() { var applePie = new Recipe("Apple pie"); applePie.AddIngredient("Apples", 200); applePie.AddIngredient("Sugar", 50); applePie.AddIngredient("Pastry", 300); applePie.Ingredients.ShouldContainKey("Apples"); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.AddIngredient(ItemID.FrostCore); recipe.AddIngredient(ItemID.IronFence, 5); recipe.AddIngredient(ModContent.ItemType <Materials.frostStone>(), 10); recipe.AddTile(TileID.Anvils); recipe.Register(); }
protected void BuildBonneMos() { Recipe r = new Recipe("bonnemos", "Bønnemos", @"Svits løg og chili. Hæl bønnerne i og mos det hele."); r.AddIngredient(400, "g", "Sorte bønner"); r.AddIngredient(2, "stk", "Løg"); r.AddIngredient(4, "stk", "Chili"); RecipeRepository.Add(r); BonneMosRecipe = r; }
public void AddIngredientTest() { Recipe food = new Recipe("food", "instruction", new Ingredient[2], 2, "cuisine", new string[] { "keyword1", "keyword2" }); Ingredient a = new Ingredient("name1", "description1", 123, "gr"); Ingredient b = new Ingredient("name2", "description2", 456, "kg"); Ingredient c = new Ingredient("name3", "description3", 789, "kg"); Assert.IsTrue(food.AddIngredient(a)); Assert.IsTrue(food.AddIngredient(b)); Assert.IsFalse(food.AddIngredient(c)); }
protected void BuildBonneMos() { Recipe r = new Recipe("bonnemos", "Bønnemos", @"Svits løg og chili. Hæl bønnerne i og mos det hele."); r.AddIngredient(400, "g", "Sorte bønner"); r.AddIngredient(2, "stk", "Løg"); r.AddIngredient(4, "stk", "Chili"); RecipeRepository.Add(r); BonneMosRecipe = r; }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.createItem = this.item.Clone(); recipe.createItem.stack = 1; recipe.AddIngredient(ItemID.ActuationRod); recipe.AddIngredient(null, "StorageComponent"); recipe.AddTile(TileID.Anvils); recipe.Register(); }
static RecipeFactory() { Recipe strongPotion = new Recipe(1, "Strong Potion"); strongPotion.AddIngredient(2001, 1); strongPotion.AddIngredient(3001, 1); strongPotion.AddIngredient(3002, 1); strongPotion.AddOutputItem(2002, 1); _recipes.Add(strongPotion); }
static RecipeFactory() { Recipe granolaBar = new Recipe(1, "Granola bar"); granolaBar.AddIngredient(3001, 1); granolaBar.AddIngredient(3002, 1); granolaBar.AddIngredient(3003, 1); granolaBar.AddOutputItem(2001, 1); _recipes.Add(granolaBar); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.createItem = this.item.Clone(); recipe.createItem.stack = 1; recipe.AddIngredient(ItemID.MeteoriteBar, 10); recipe.AddIngredient(ItemID.Amber, 5); recipe.AddTile(TileID.Anvils); recipe.Register(); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.createItem = this.item.Clone(); recipe.createItem.stack = 1; recipe.AddIngredient(ItemID.MartianConduitPlating, 25); recipe.AddIngredient(ItemID.LunarBar, 5); recipe.AddTile(TileID.LunarCraftingStation); recipe.Register(); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(ItemID.AvengerEmblem); recipe.AddIngredient(ModContent.ItemType <ClickerEmblem>(), 1); recipe.AddIngredient(ItemID.SoulofMight, 5); recipe.AddIngredient(ItemID.SoulofSight, 5); recipe.AddIngredient(ItemID.SoulofFright, 5); recipe.AddTile(TileID.TinkerersWorkbench); recipe.Register(); }
static RecipeFactory() { Recipe granolaBar = new Recipe(1, "Cereálie", "Po pozření doplní 4 HP a 40 Many. Ingredience: 1 Rozinky, 1 Oves, 1 Med"); granolaBar.AddIngredient(3001, 1); granolaBar.AddIngredient(3002, 1); granolaBar.AddIngredient(3003, 1); granolaBar.AddOutputItem(2001, 1); _recipes.Add(granolaBar); }
public void DataAccessDemo() { // Arrange var recipeRepository = _container.Resolve <IRepository <Recipe> >(); var recipeCategoryRepository = _container.Resolve <IRepository <RecipeCategory> >(); var ingredientRepository = _container.Resolve <IRepository <Ingredient> >(); // Act var italianCategory = new RecipeCategory { Name = "Italian" }; var chineseCategory = new RecipeCategory { Name = "Chinese" }; recipeCategoryRepository.Create(italianCategory); recipeCategoryRepository.Create(chineseCategory); var recipe = new Recipe { Name = "Pizza", Category = italianCategory }; recipeRepository.Create(recipe); var ingredient1 = new Ingredient { Name = "Pizza crust", Quantity = 1, Unit = QuantityUnit.Pieces }; var ingredient2 = new Ingredient { Name = "Tomato sauce", Quantity = 0.2f, Unit = QuantityUnit.Liter }; var ingredient3 = new Ingredient { Name = "Cheese", Quantity = 0.3f, Unit = QuantityUnit.Kilogram }; var ingredient4 = new Ingredient { Name = "Spinach", Quantity = 0.01f, Unit = QuantityUnit.Kilogram }; ingredientRepository.Create(ingredient1); ingredientRepository.Create(ingredient2); ingredientRepository.Create(ingredient3); ingredientRepository.Create(ingredient4); recipe.AddIngredient(ingredient1); recipe.AddIngredient(ingredient2); recipe.AddIngredient(ingredient3); recipe.AddIngredient(ingredient4); // Assert Assert.Greater(recipe.Id, 0); Assert.IsTrue(recipe.Ingredients.Contains(ingredient1)); }
public void ShouldAddIngredients() { var applePie = new Recipe("Apple Pie"); applePie.AddIngredient("Apples", 200); applePie.AddIngredient("Sugar", 50); applePie.AddIngredient("Pastry", 300); applePie.Ingredients.ShouldContainKey("Apples"); applePie.Ingredients.ShouldNotContainKey("Cherries"); applePie.Ingredients.ShouldContainKeyAndValue("Sugar", 50); applePie.Ingredients.ShouldNotContainValueForKey("Sugar", 150); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); recipe.createItem = this.item.Clone(); recipe.createItem.stack = 1; recipe.AddIngredient(ItemID.Wood, 16); recipe.AddIngredient(ItemID.IronBar); //recipe.anyWood = true; //recipe.anyIronBar = true; recipe.AddTile(TileID.WorkBenches); recipe.Register(); }
public void SaveAndRestore() { Recipe originalRecipe = new Recipe(); originalRecipe.Name = CHEESEBURGER; originalRecipe.AddIngredient(SIRLOIN); originalRecipe.AddIngredient(CHEESE); originalRecipe.AddIngredient(BACON); Stream recipeStream; RecipeFile filer; using (recipeStream = File.OpenWrite(RECIPE_FILE_NAME)) { filer = new RecipeFile(); filer.Save(recipeStream, originalRecipe); } // Now get it back Recipe reconstitutedRecipe; using (recipeStream = File.OpenRead(RECIPE_FILE_NAME)) { filer = new RecipeFile(); reconstitutedRecipe = filer.Load(recipeStream); } Assert.That( reconstitutedRecipe.Name, Is.EqualTo(originalRecipe.Name) ); int originalIngredientCount = originalRecipe.Ingredients.Count; Assert.That( reconstitutedRecipe.Ingredients.Count, Is.EqualTo(originalIngredientCount) ); for (int i = 0; i < originalIngredientCount; i++) { Assert.That( reconstitutedRecipe.Ingredients[i], Is.EqualTo(originalRecipe.Ingredients[i]) ); } }
public void RemoveIngredient() { var rec = new Recipe("Rec"); bool result = false; rec.AddIngredient("mel", (100, Unit.g)); rec.AddIngredient("mælk", (1, Unit.dl)); result = rec.PrintIngredientList() == "100 g mel \n1 dl mælk \n"; rec.RemoveIngredient("mælk"); result &= rec.PrintIngredientList() == "100 g mel \n"; Assert.IsTrue(result); }
public override void AddRecipes() { Recipe recipe = CreateRecipe(); foreach (int ench in Enchants) { recipe.AddIngredient(ench); } recipe.AddIngredient(ModContent.ItemType <Eridanium>(), 5); recipe.AddTile(ModContent.Find <ModTile>("Fargowiltas", "CrucibleCosmosSheet")); recipe.Register(); }
public void SolutionModify() { var item1 = new Item("a"); var item2 = new Item("b"); Recipe r = new Recipe(""); r.AddIngredient(new ItemAmount(item1, 1)); r.AddResult(new ItemAmount(item2, 1)); r.CraftingCategory = "test"; Building b = new Building(""); b.AddCraftingCategory("test"); b.IngredientCount = 4; b.ProductionSpeed = 1; Library l = new Library(); l.AddItem(item1); l.AddItem(item2); l.AddRecipe(r); l.AddBuilding(b); l.Initialize(); var coarseGraph = RecipeGraph.FromLibrary(l, new Item[] { item1 }, new ItemAmount[] { new ItemAmount(item2, 0.01) }, (a) => 1); var denseGraph = TrivialSolutionFactory.CreateFactory(coarseGraph); var parameters = SolutionParameters.FromFactory(12, 12, denseGraph); Assert.AreEqual(parameters, parameters.Modify(0)); }
private async Task CreateIngredients(Recipe recipe, List <CreateRecipeIngredientDto> ingredientModels) { var productIds = await _productsRepository.GetProductIdsByGuids(ingredientModels.Select(x => x.ProductGuid)); var productMeasures = await _productMeasuresRepository.GetProductMeasureBaseByGuids(ingredientModels.Select(x => x.ProductMeasureGuid)); foreach (var ingredientModel in ingredientModels) { var productId = productIds.FirstOrDefault(x => x.ProductGuid == ingredientModel.ProductGuid); var measure = productMeasures.FirstOrDefault(x => x.ProductMeasureGuid == ingredientModel.ProductMeasureGuid); if (productId == null) { throw new DomainException(ErrorCode.ProductNotExists, new { ingredientModel.ProductGuid }); } if (measure == null) { throw new DomainException(ErrorCode.ProductMeasureNotFound, new { ingredientModel.ProductMeasureGuid }); } var ingredient = new Ingredient(_guid.GetGuid(), productId.ProductId, measure.ProductMeasureId, ingredientModel.Amount, ingredientModel.Amount * measure.ValueInGrams, ingredientModel.Note); recipe.AddIngredient(ingredient); } }
protected void BuildMexicanskeBurritos() { Recipe r = new Recipe("mexicanske-burritos", "Mexicanske burritos", @"Snit salat, skær tomat i både og løg og agurk i tern. Åben for dåsen med majs. Tænd ovnen på 180º C varmluft/200º C alm. ovn. Svits kødet i en gryde. Tilsæt krydderi og vand, og lad det simre ca. 5 min. Fyld de mexicanske wraps med kødet. Rul dem sammen, og læg dem i et ildfast fad. Drys osten udover. Gratineres i ovnen i ca. 10 minutter. Serverer de varme wraps med salat, creme fraiche og salsa til."); r.AddIngredient(0.5f, "stk", "Hovedsalat"); r.AddIngredient(200, "g", "Cherry tomater"); r.AddIngredient(1, "stk", "Rødløg"); r.AddIngredient(1, "stk", "Agurk"); r.AddIngredient(1, "ds", "Majs på dåse"); RecipeRepository.Add(r); MexicanskeBurritosRecipe = r; }