private DrinkRecipe CreateDrinkRecipe(params IngredientParameter[] parameters) { if (parameters == null) { throw new ArgumentNullException(); } if (parameters.Length <= 0 || parameters.Length > 6) { throw new ArgumentException(); } var result = new DrinkRecipe(); result.Name = "Test"; var drinkIngredients = parameters.Select(parameter => new DrinkIngredient(parameter.Milliliter) { Ingredient = new Ingredient() { BottleIndex = parameter.BottleIndex } }) .ToList(); result.DrinkIngredients = drinkIngredients; return(result); }
public DrinkRecipeViewModel(DrinkRecipe drinkRecipe) { if (drinkRecipe == null) { throw ExceptionFactory.Get <ArgumentNullException>("'drinkRecipe' was null'"); } if (drinkRecipe.DrinkIngredients == null) { throw ExceptionFactory.Get <ArgumentNullException>("'drinkRecipe.DrinkIngredients' was null'"); } if (string.IsNullOrWhiteSpace(drinkRecipe.Name)) { throw ExceptionFactory.Get <ArgumentNullException>("'drinkRecipe.Name' was null'"); } Id = drinkRecipe.Id; Name = drinkRecipe.Name; ByteImage = drinkRecipe.ByteImage; DrinkRecipe = drinkRecipe; MapModelWithViewModel(drinkRecipe); }
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 SpawnGlass(int recipeIndex = -1) { //timeCounter = 0; if (recipeIndex == -1) { recipeIndex = Random.Range(0, levels[level]); } DrinkRecipe recipe = recipes[recipeIndex]; Glass glass = Instantiate <Glass>(glasses[recipe.cupSize]); glass.recipe = recipe; glass.transform.position = this.transform.position; glass.GetComponent <move>().speed = speeds[level]; ObjectFollowerUI ofui = Instantiate <ObjectFollowerUI>(labelPrefab); ofui.GetComponent <RectTransform>().SetParent(labelCanvas.GetComponent <RectTransform>()); ofui.transform.position = labelPrefab.transform.position; ofui.text.text = recipe.drinkName.ToUpper(); ofui.objectToFollow = glass.transform; glass.label = ofui.gameObject; audiosource.Play(); audiosource.pitch = 1.2f - (0.2f * recipe.cupSize) + Random.Range(-0.2f, 0.2f); audiosource.time = audioDelay; }
public async void drinkFetch(string sf) { var client = new HttpClient(); DrinkRecipe recipe = new DrinkRecipe(); var recipeurl = "https://www.thecocktaildb.com/api/json/v1/1/search.php?s=" + sf; var uri = new Uri(recipeurl); var response = await client.GetAsync(uri); var jsoncontent = await response.Content.ReadAsStringAsync(); if (jsoncontent == "{\"drinks\":null}") { await DisplayAlert("error", "no recipe found. check spelling", "ok"); } else { recipe = JsonConvert.DeserializeObject <DrinkRecipe>(jsoncontent); DrinkRecipeListView.ItemsSource = new ObservableCollection <Drink>(recipe.Drinks); activity.IsRunning = false; activity.IsEnabled = false; activity.IsVisible = false; } }
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 static void ShowRecipe(DrinkRecipe _recipe) { if (_recipe != null) { if (instance.lastRecipe == null) { beforeTutorial = false; isTutorial = true; instance.tutorialStep = 0; instance.lastRecipe = _recipe; instance.NextHelp(); } else { instance.popup.Show(); instance.drinkName.text = _recipe.drinkName; string r = "Recipe:\n"; for (int i = 0; i < _recipe.ingredients.Length; ++i) { r += "" + (int)(_recipe.amounts[i] / 50) + "x " + _recipe.ingredients[i].ToString(); if (i < _recipe.ingredients.Length - 1) { r += "\n"; } } instance.recipe.text = r; AudioBend.Pause(); instance.lastRecipe = _recipe; } } }
private DrinkRecipe CreateDrinkRecipe(params int[] bottleIndexes) { if (bottleIndexes == null) { throw new ArgumentNullException(); } if (bottleIndexes.Length <= 0 || bottleIndexes.Length > 6) { throw new ArgumentException(); } if (bottleIndexes.Any(i => i > 6 || i < 1)) { throw new ArgumentException(); } var result = new DrinkRecipe(); result.Name = "Test"; var drinkIngredients = bottleIndexes.Select(bottleIndex => new DrinkIngredient(It.IsAny <int>()) { Ingredient = new Ingredient() { BottleIndex = bottleIndex } }) .ToList(); result.DrinkIngredients = drinkIngredients; return(result); }
public void DrinkRecipeConstructorTest() { DrinkRecipe recipe = new DrinkRecipe("Test Recipe"); Assert.AreEqual("Test Recipe", recipe.Name); Assert.IsFalse(recipe.Ingredients.Any()); Assert.IsNull(recipe.FirstStep); }
public void DrinkRecipeCanMakeRecipeTrueNoIngredentsTest() { DrinkRecipe recipe = new DrinkRecipe("Test Recipe"); recipe.FirstStep = new RecipeStepCall(new AddStep()); Assert.IsTrue(recipe.CanMakeFromRecipes(new List <String> { "TestIngredient1", "TestIngredient2", "TestIngredient3" })); }
public void ToByteArray_OnlyFiveIngredients_Result_LastThreeBytesShouldBeZero() { // arrange var drinkRecipe = new DrinkRecipe(); var drinkIngredients = new List <DrinkIngredient>() { new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 1 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 2 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 3 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 4 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 5 } }, }; drinkRecipe.DrinkIngredients = drinkIngredients; // act //var result = drinkRecipe.ToByteArray(); // assert var shouldBe = new byte[23] { 0xFF, 0xFF, 1, 0, 50, 2, 0, 50, 3, 0, 50, 4, 0, 50, 5, 0, 50, 0, 0, 0, 0xFF, 0xFF, 0x00 }; // CollectionAssert.AreEqual(shouldBe, result); }
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 ExactDrinkorder(DrinkRecipe recipe, string ordererName) : base(DrinkOrderType.Exact, recipe.DrinkName) { Recipe = recipe; OrdererName = ordererName; DrinkPredicates = new List <DrinkPredicate>() { GlassHasContents, new DrinkPredicate(testDrink => DrinkState.IsIdentical(recipe.Contents, testDrink), IncorrectDrinkReason.WrongRecipe) }; }
public async Task <bool> InsertWithChildrenAsync(DrinkRecipe drink) { if (await IsInserted(drink)) { return(false); } await Component.Connection.InsertOrReplaceWithChildrenAsync(drink, true); return(true); }
public void DrinkRecipeCanMakeRecipeFalseNoIngredientTest() { DrinkRecipe recipe = new DrinkRecipe("Test Recipe"); recipe.FirstStep = new RecipeStepCall(new AddStep()); recipe.Ingredients.Add(new Ingredient("TestIngredient1", 1, IngredientUnit.Dash, "Test Ingredient 1")); recipe.Ingredients.Add(new Ingredient("NonexistentIngredient", 1, IngredientUnit.Dash, "Test Ingredient 2")); Assert.IsFalse(recipe.CanMakeFromRecipes(new List <String> { "TestIngredient1", "TestIngredient2", "TestIngredient3" })); }
public static void CreateMyAsset() { DrinkRecipe asset = ScriptableObject.CreateInstance <DrinkRecipe>(); AssetDatabase.CreateAsset(asset, "Assets/Recipes/NewRecipe.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; }
public void DrinkRecipeCanMakeRecipeTrueWithWhippedToppingTest() { DrinkRecipe recipe = new DrinkRecipe("Test Recipe"); recipe.FirstStep = new RecipeStepCall(new AddStep()); recipe.Ingredients.Add(new Ingredient("TestIngredient1", 1, IngredientUnit.Dash, "Test Ingredient 1")); recipe.Ingredients.Add(new Ingredient("TestIngredient2", 1, IngredientUnit.Dash, "Test Ingredient 2")); recipe.Ingredients.Add(new Ingredient("WhippedCreamIngredient", 1, IngredientUnit.Whipped_Cream, "Test Ingredient 2")); Assert.IsTrue(recipe.CanMakeFromRecipes(new List <String> { "TestIngredient1", "TestIngredient2", "TestIngredient3" })); }
public void AddRecipe(DrinkRecipe recipe) { var recipeUI = Instantiate(recipeTemplate); recipeUI.transform.SetParent(recipeContentPane.transform); recipeUI.transform.Find(RecipeToNamePath).GetComponent <Text>().text = recipe.DrinkName; foreach (var ingredient in recipe.Contents.GetContents()) { var ingredientUI = Instantiate(ingredientTemplate); ingredientUI.transform.SetParent(recipeUI.transform); ingredientUI.transform.Find(IngredientToNamePath).GetComponent <Text>().text = ingredient.Key != Ingredient.Beer ? ingredient.Key.ToString() : "Bottled"; ingredientUI.transform.Find(IngredientToAmountPath).GetComponent <Text>().text = ingredient.Key != Ingredient.Beer ? ingredient.Value.ToString() : ""; } }
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); }
public bool IsEqual(DrinkRecipe recipeB) { if (recipeB.Steps.Count != Steps.Count) { return(false); } for (int i = 0; i < Steps.Count; i++) { if (!Steps[i].IsEqual(recipeB.Steps[i])) { return(false); } } return(true); }
public IEnumerator ShowRoutine(DrinkRecipe recipe, List <AlienLetter> alternatives) { yield return(new WaitForFixedUpdate()); var recipeData = recipe.GetRowData(alternatives); if (IsLoggingDebug) { Debug.Log(recipe); } foreach (var rowData in recipeData) { var newRow = Instantiate(RowPrefab); newRow.transform.SetParent(RowParent); newRow.transform.SetAsFirstSibling(); newRow.GetComponent <SpeechRow>().SetAppearance(rowData); } }
public async Task UpsertWithChildrenAsync(DrinkRecipe drink) { var drinkIngredients = drink.DrinkIngredients; foreach (var di in drinkIngredients) { di.DrinkId = drink.Id; } var dBIngredients = await Component.Connection.Table <DrinkIngredient>() .Where(di => di.DrinkId == drink.Id) .ToListAsync(); var shouldBeDeleted = dBIngredients. Where(dbIngredient => drinkIngredients.All(di => di.IngredientId != dbIngredient.IngredientId)) .ToList(); await _drinkIngredientRepository.DeleteAsync(shouldBeDeleted); foreach (var drinkIngredient in drinkIngredients) { var doesExist = dBIngredients.Any(di => di.IngredientId == drinkIngredient.IngredientId && di.DrinkId == drinkIngredient.DrinkId); if (doesExist) { await _drinkIngredientRepository.UpdateAsync(drinkIngredient); } else { await _drinkIngredientRepository.InsertAsync(drinkIngredient); } } using var connection = new SQLiteConnection(Component.Connection.DatabasePath); var command = new SQLiteCommand(connection); command.CommandText = $"update {TableNames.DrinkRecipeTable} set Name = @name, ByteImage = @byteImage " + $"where Id = '{drink.Id}'"; command.Bind("@name", drink.Name); command.Bind("@byteImage", drink.ByteImage); command.ExecuteNonQuery(); }
public void Show(DrinkRecipe _recipe) { this.recipe = _recipe; recipeName.text = recipe.name; for (int i = 0; i < ingredients.Length; ++i) { if (i < recipe.ingredients.Length) { ingredients[i].color = LiquidGenarate.liquidColor[recipe.ingredients[i]]; } else { ingredients[i].color = defaultColor; } } minirecipes++; GetComponent <Popup>().Show(); }
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); }
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, })); }
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); }
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, })); }
public void ToByteArray_BottleIndexIsNotOrdered_ResultShouldBeOrderedAscending() { // arrange var drinkRecipe = new DrinkRecipe(); var drinkIngredients = new List <DrinkIngredient>() { new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 6 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 1 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 5 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 3 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 2 } }, new DrinkIngredient() { Milliliter = 50, Ingredient = new Ingredient() { BottleIndex = 4 } } }; drinkRecipe.DrinkIngredients = drinkIngredients; // act //var result = drinkRecipe.ToByteArray(); // assert var shouldBe = new byte[23] { 0xFF, 0xFF, 1, 0, 50, 2, 0, 50, 3, 0, 50, 4, 0, 50, 5, 0, 50, 6, 0, 50, 0xFF, 0xFF, 0x00 }; //CollectionAssert.AreEqual(shouldBe, result); }
private async Task <bool> IsInserted(DrinkRecipe drink) { var isInserted = await Component.Connection.Table <DrinkRecipe>().CountAsync(d => d.Name == drink.Name) > 0; return(isInserted); }
public Task UpdateWithChildrenAsync(DrinkRecipe drink) { return(Component.Connection.UpdateWithChildrenAsync(drink)); }