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 RecipeStepCallDefaultConstructorTest() { RecipeStepCall stepCall = new RecipeStepCall(null); Assert.AreEqual(false, stepCall.IsDone); Assert.AreEqual(false, stepCall.IsValid); Assert.AreEqual(String.Empty, stepCall.MessageToUser); Assert.AreEqual(String.Empty, stepCall.NextGrammarNeeded); Assert.AreEqual(false, stepCall.ShouldCancel); }
public void DrinkRecipeStartTest() { DrinkRecipe recipe = new DrinkRecipe("Test Recipe"); recipe.FirstStep = new RecipeStepCall(new AddStep()); RecipeStepCall firstStep = recipe.Start(); Assert.AreNotSame(recipe.FirstStep, firstStep); Assert.AreEqual(recipe.FirstStep, firstStep); }
public void RecipeStepCallNoNextConstructorTest() { MockRecipeStep mockStep = new MockRecipeStep("messageToUser", "nextGrammarNeeded", true, true, true); RecipeStepCall stepCall = new RecipeStepCall(mockStep); Assert.AreEqual(true, stepCall.IsDone); Assert.AreEqual(true, stepCall.IsValid); Assert.AreEqual(mockStep.MessageToUser, stepCall.MessageToUser); Assert.AreEqual(mockStep.NextGrammarNeeded, stepCall.NextGrammarNeeded); Assert.AreEqual(mockStep.ShouldCancel, stepCall.ShouldCancel); }
public void RecipeGetIgniteRecipeStepCallTest() { RecipeStepFactory factory = new RecipeStepFactory(); RecipeStepCall recipeStepCall = factory.GetRecipeStepCall("Ignite"); Assert.IsNotNull(recipeStepCall._step); Assert.IsTrue(recipeStepCall._step is IgniteStep); Assert.IsFalse(recipeStepCall is RecipeStepCall <Ingredient>); recipeStepCall = factory.GetRecipeStepCall <Ingredient>("Ignite", new Ingredient("TestIngredient", 1, IngredientUnit.Dash, "Test Ingredient")); Assert.IsNull(recipeStepCall._step); }
public void RecipeStepCallCallNoAdvanceTest() { MockRecipeStep mockNextStep = new MockRecipeStep("messageToUser", "nextGrammarNeeded", false, false, false); RecipeStepCall nextStepCall = new RecipeStepCall(mockNextStep); MockRecipeStep mockStep = new MockRecipeStep("messageToUser", "nextGrammarNeeded", false, false, false); RecipeStepCall stepCall = new RecipeStepCall(mockStep, nextStepCall); Mock <IBartenderController> bartender = new Mock <IBartenderController>(MockBehavior.Strict); bartender.Setup(s => s.IsValid).Returns(true); Assert.AreEqual(stepCall, stepCall.Call(new Dialog(new Dictionary <String, String>(), "Phrase"), bartender.Object)); Assert.AreEqual(true, mockStep.DoStepIsCalled); Assert.AreEqual(false, mockNextStep.DoStepIsCalled); }
public void RecipeStepCallCloneTest() { MockRecipeStep mockNextStep = new MockRecipeStep("messageToUser", "nextGrammarNeeded", false, false, true); RecipeStepCall nextStepCall = new RecipeStepCall(mockNextStep); MockRecipeStep mockStep = new MockRecipeStep("messageToUser", "nextGrammarNeeded", false, false, true); RecipeStepCall stepCall = new RecipeStepCall(mockStep, nextStepCall); RecipeStepCall clonedCall = stepCall.Clone() as RecipeStepCall; Assert.AreNotSame(clonedCall, stepCall); Mock <IBartenderController> bartender = new Mock <IBartenderController>(MockBehavior.Strict); bartender.Setup(s => s.IsValid).Returns(true); clonedCall.Call(new Dialog(new Dictionary <String, String>(), "Phrase"), bartender.Object); Assert.IsFalse(mockStep.DoStepIsCalled); Assert.IsFalse(mockNextStep.DoStepIsCalled); }
private DrinkRecipeProvider GetProvider() { DrinkRecipe recipe1 = new DrinkRecipe("Recipe 1"); recipe1.Ingredients.Add(new Ingredient("testLiquid1", 1, IngredientUnit.Part, "testLiquid1")); recipe1.Ingredients.Add(new Ingredient("testLiquid2", 1, IngredientUnit.Part, "testLiquid2")); RecipeStepCall call = new RecipeStepCall(new StirStep()); recipe1.FirstStep = call; DrinkRecipe recipe2 = new DrinkRecipe("Recipe 2"); recipe2.Ingredients.Add(new Ingredient("testLiquid1", 1, IngredientUnit.Part, "testLiquid1")); recipe2.Ingredients.Add(new Ingredient("testLiquid2", 1, IngredientUnit.Part, "testLiquid2")); recipe2.Ingredients.Add(new Ingredient("testLiquid3", 1, IngredientUnit.Part, "testLiquid3")); call = new RecipeStepCall(new StirStep()); recipe2.FirstStep = call; return(new DrinkRecipeProvider(new List <DrinkRecipe> { recipe1, recipe2, })); }
private DrinkRecipeProvider GetProvider() { DrinkRecipe recipe1 = new DrinkRecipe("Recipe 1"); recipe1.Ingredients.Add(new Ingredient("testLiquid1", 1, IngredientUnit.Part, "testLiquid1")); recipe1.Ingredients.Add(new Ingredient("testLiquid2", 1, IngredientUnit.Part, "testLiquid2")); RecipeStepCall call = new RecipeStepCall(new MockRecipeStep(String.Empty, String.Empty, true, false, true)); recipe1.FirstStep = call; call.AddNextStep(new RecipeStepCall(new MockRecipeStep("Testing request", BartenderApp.ConfirmationRuleName, false, false, false))); call._nextStep.AddNextStep(new RecipeStepCall(new MockRecipeStep("Testing Finish", String.Empty, true, false, true))); DrinkRecipe recipe2 = new DrinkRecipe("Recipe 2"); recipe2.Ingredients.Add(new Ingredient("testLiquid1", 1, IngredientUnit.Part, "testLiquid1")); recipe2.Ingredients.Add(new Ingredient("testLiquid2", 1, IngredientUnit.Part, "testLiquid2")); recipe2.Ingredients.Add(new Ingredient("testLiquid3", 1, IngredientUnit.Part, "testLiquid3")); call = new RecipeStepCall(new MockRecipeStep(String.Empty, String.Empty, true, false, true)); recipe2.FirstStep = call; call.AddNextStep(new RecipeStepCall(new MockRecipeStep("Testing request", BartenderApp.ConfirmationRuleName, false, false, false))); call._nextStep.AddNextStep(new RecipeStepCall(new MockRecipeStep("Testing Cancel", String.Empty, false, true, false))); DrinkRecipe recipe3 = new DrinkRecipe("Recipe 3"); recipe3.Ingredients.Add(new Ingredient("testLiquid1", 1, IngredientUnit.Part, "testLiquid1")); recipe3.Ingredients.Add(new Ingredient("testLiquid2", 1, IngredientUnit.Part, "testLiquid2")); call = new RecipeStepCall(new MockRecipeStep(String.Empty, String.Empty, true, false, true)); recipe3.FirstStep = call; call.AddNextStep(new RecipeStepCall(new MockRecipeStep("Testing request", BartenderApp.ConfirmationRuleName, false, false, false))); call._nextStep.AddNextStep(new RecipeStepCall(new MockRecipeStep(String.Empty, String.Empty, true, false, true))); return(new DrinkRecipeProvider(new List <DrinkRecipe> { recipe1, recipe2, recipe3, })); }