public void DrinkRecipeCreateFromXmlStepsIngredientArgumentsTest() { String xmlFile = "<Drink Key=\"testdrink\" Name=\"Raspberry Champagne\" Glass=\"Champagne\"><Ingredients><Ingredient Key=\"black_raspberry_liqueur\" Quantity=\"1\" Unit=\"dash\" /><Ingredient Key=\"champagne\" Quantity=\"5\" Unit=\"dash\" /></Ingredients><Steps><Step Type=\"Pour\" Arguments=\"champagne,black_raspberry_liqueur\" /></Steps></Drink>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlFile); DrinkRecipe recipe = DrinkRecipe.CreateFromXml(doc.LastChild, new Dictionary <String, String> { { "black_raspberry_liqueur", "Black Raspberry Liqueur" }, { "champagne", "Champagne" }, }, new Dictionary <String, double> { { "Champagne", 200 }, }); // Test Steps Assert.IsTrue(recipe.FirstStep._nextStep is RecipeStepCall <Ingredient>); Assert.IsTrue(recipe.FirstStep._nextStep._step is PourStep); RecipeStepCall <Ingredient> stepCall = recipe.FirstStep._nextStep as RecipeStepCall <Ingredient>; Assert.AreEqual(new Ingredient("champagne", 5, IngredientUnit.Dash, "Champagne"), stepCall._argument); Assert.IsTrue(recipe.FirstStep._nextStep._nextStep._step is PourStep); Assert.IsTrue(recipe.FirstStep._nextStep._nextStep is RecipeStepCall <Ingredient>); stepCall = recipe.FirstStep._nextStep._nextStep as RecipeStepCall <Ingredient>; Assert.AreEqual(new Ingredient("black_raspberry_liqueur", 1, IngredientUnit.Dash, "Black Raspberry Liqueur"), stepCall._argument); }
public void DrinkRecipeCreateFromXmlIngredientsMixedAmountsLargeFixedTest() { String xmlFile = "<Drink Key=\"testdrink\" Name=\"Raspberry Champagne\" Glass=\"Collins\"><Ingredients><Ingredient Key=\"black_raspberry_liqueur\" Quantity=\"1\" Unit=\"part\" /><Ingredient Key=\"champagne\" Quantity=\"500\" Unit=\"dash\" /></Ingredients><Steps><Step Type=\"Stir\" /></Steps></Drink>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlFile); DrinkRecipe recipe = DrinkRecipe.CreateFromXml(doc.LastChild, new Dictionary <String, String> { { "black_raspberry_liqueur", "Black Raspberry Liqueur" }, { "champagne", "Champagne" }, }, new Dictionary <String, double> { { "Collins", 400 }, }); // Test ingredients Assert.AreEqual(2, recipe.Ingredients.Count); Ingredient raspberryIngredient = recipe.Ingredients.SingleOrDefault(i => i.Name.Equals("Black Raspberry Liqueur")); Assert.IsNotNull(raspberryIngredient); Assert.AreEqual(400, (int)raspberryIngredient.AmountQuantityInmL); Assert.AreEqual(1, raspberryIngredient.AmountQuantity); Assert.AreEqual(IngredientUnit.Part, raspberryIngredient.AmountUnit); Ingredient chammpaigneIngredient = recipe.Ingredients.SingleOrDefault(i => i.Name.Equals("Champagne")); Assert.IsNotNull(chammpaigneIngredient); Assert.AreEqual(500, (int)chammpaigneIngredient.AmountQuantityInmL); Assert.AreEqual(500, chammpaigneIngredient.AmountQuantity); Assert.AreEqual(IngredientUnit.Dash, chammpaigneIngredient.AmountUnit); }
public void DrinkRecipeCreateFromXmlIngredientsInvalidIngredientNameTest() { String xmlFile = "<Drink Key=\"testdrink\" Name=\"Raspberry Champagne\" Glass=\"Champagne\"><Ingredients><Ingredient Key=\"black_raspberry_liqueur\" Quantity=\"1\" Unit=\"part\" /><Ingredient Key=\"champagne\" Quantity=\"5\" Unit=\"dash\" /></Ingredients><Steps><Step Type=\"Stir\" /></Steps></Drink>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlFile); DrinkRecipe recipe = DrinkRecipe.CreateFromXml(doc.LastChild, new Dictionary <String, String> { { "black_raspberry_liqueur", "Black Raspberry Liqueur" }, }, new Dictionary <String, double> { { "Champagne", 200 }, }); Assert.IsNull(recipe); }
private static void TestGlass(String glassName, int glassVolume) { String xmlFile = String.Format("<Drink Key=\"testdrink\" Name=\"Raspberry Champagne\" Glass=\"{0}\"><Ingredients><Ingredient Key=\"black_raspberry_liqueur\" Quantity=\"1\" Unit=\"part\" />></Ingredients><Steps><Step Type=\"Stir\" /></Steps></Drink>", glassName); XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlFile); DrinkRecipe recipe = DrinkRecipe.CreateFromXml(doc.LastChild, new Dictionary <String, String> { { "black_raspberry_liqueur", "Black Raspberry Liqueur" }, }, new Dictionary <String, double> { { glassName, glassVolume }, }); Ingredient raspberryIngredient = recipe.Ingredients.SingleOrDefault(); Assert.IsNotNull(raspberryIngredient); Assert.AreEqual(glassVolume, (int)raspberryIngredient.AmountQuantityInmL); recipe.FirstStep.Call(null, null); Assert.AreEqual(String.Format("Place a {0} glass underneath the spout of the bartender so I can make you a Raspberry Champagne.", glassName), recipe.FirstStep.MessageToUser); }
public void DrinkRecipeProviderConstructorTest() { String recipe1XmlFile = "<Drink Key=\"testdrink\" Name=\"Test Drink\" Glass=\"Champagne\"><Ingredients><Ingredient Key=\"black_raspberry_liqueur\" Quantity=\"1\" Unit=\"dash\" /><Ingredient Key=\"champagne\" Quantity=\"5\" Unit=\"dash\" /></Ingredients><Steps><Step Type=\"Pour\" Arguments=\"champagne,black_raspberry_liqueur\" /></Steps></Drink>"; String recipe2XmlFile = "<Drink Key=\"testdrink2\" Name=\"Test Drink 2\" Glass=\"Champagne\"><Ingredients><Ingredient Key=\"black_raspberry_liqueur\" Quantity=\"1\" Unit=\"dash\" /><Ingredient Key=\"champagne\" Quantity=\"5\" Unit=\"dash\" /></Ingredients><Steps><Step Type=\"Stir\" /></Steps></Drink>"; String xmlFile = String.Format("<DrinkRecipes><Cocktails>{0}{1}</Cocktails><Ingredients><Ingredient Key=\"champagne\" CabinetShelf=\"None\" Name=\"Champagne\"/><Ingredient Key=\"black_raspberry_liqueur\" CabinetShelf=\"None\" Name=\"Black Raspberry Liqueur\"/></Ingredients><Glasses><Glass Name=\"Champagne\" Volume=\"200\" /></Glasses></DrinkRecipes>", recipe1XmlFile, recipe2XmlFile); XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlFile); DrinkRecipeProvider provider = new DrinkRecipeProvider(doc); Assert.AreEqual(2, provider.Drinks.Count); DrinkRecipe testDrinkRecipe = provider.Drinks.SingleOrDefault(d => d.Name.Equals("Test Drink")); XmlDocument recipe1Doc = new XmlDocument(); recipe1Doc.LoadXml(recipe1XmlFile); Assert.AreEqual(DrinkRecipe.CreateFromXml(recipe1Doc.LastChild, new Dictionary <String, String> { { "black_raspberry_liqueur", "Black Raspberry Liqueur" }, { "champagne", "Champagne" }, }, new Dictionary <String, double> { { "Champagne", 200 }, }), testDrinkRecipe); DrinkRecipe testDrink2Recipe = provider.Drinks.SingleOrDefault(d => d.Name.Equals("Test Drink 2")); XmlDocument recipe2Doc = new XmlDocument(); recipe2Doc.LoadXml(recipe2XmlFile); Assert.AreEqual(DrinkRecipe.CreateFromXml(recipe2Doc.LastChild, new Dictionary <String, String> { { "black_raspberry_liqueur", "Black Raspberry Liqueur" }, { "champagne", "Champagne" }, }, new Dictionary <String, double> { { "Champagne", 200 }, }), testDrink2Recipe); }