Exemplo n.º 1
0
 public void ActualitzarIdIngredient()
 {
     
     Recepta recepta = new Recepta("ProvaRecepta23e");
     string idAnt;
     Ingredient ingredient = new Ingredient(new Producte("ProvaProducte28934"), recepta, 100);
     idAnt = ingredient.PrimaryKey;
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     recepta.PrimaryKey = "NouIDRecepta";
     control.ComprovaActualitzacions(recepta);
     control.ComprovaActualitzacions(ingredient);
     Assert.AreNotEqual(idAnt, ingredient.PrimaryKey);
 }
Exemplo n.º 2
0
 public void ActualitzarDadesIngredient()
 {
     Recepta recepta = new Recepta("ProvaRecepta23e");
     Producte producte = new Producte("ProvaProducte2394");
     Ingredient ingredient = new Ingredient(producte, recepta, 100);
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     ingredient.Quantitat = 12344;
     control.ComprovaActualitzacions(ingredient);
     Ingredient ingredientDessat = null;
     SortedList<string, Ingredient> indexProductes = new SortedList<string, Ingredient>();
     foreach (Ingredient producteD in Ingredient.IngredientsDessats(bdProves))
         indexProductes.Add(producteD.PrimaryKey, producteD);
     try
     {
         ingredientDessat = indexProductes[ingredient.PrimaryKey];
     }
     catch {ingredientDessat= new Ingredient(producte, recepta, 100); }
     if(ingredientDessat!=null)
     Assert.AreEqual(ingredient.Quantitat, ingredientDessat.Quantitat);//si esta bien!!
     
 }
Exemplo n.º 3
0
 public void DonarDeAltaIngredient()
 {
     Recepta recepta = new Recepta("ProvaRecepta98");
     Ingredient ingredient = new Ingredient(new Producte("ProvaProducte234"),recepta, 100);
     
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     Assert.AreEqual(true, bdProves.CompruebaSiFunciona(ingredient.StringConsultaSql()));
 }
Exemplo n.º 4
0
 public void DonarDeBaixaIngredientDonantDeBaixaRecepta()
 {
     Recepta recepta = new Recepta("ProvaRecepta423");
     Ingredient ingredient = new Ingredient(new Producte("ProvaProducte69234"), recepta, 100);
     control.Afegir((ObjecteSql)recepta);
     control.Afegir((ObjecteSql)ingredient.Producte.ReceptaOriginal);
     control.Afegir((ObjecteSql)ingredient.Producte);
     control.Afegir((ObjecteSql)ingredient);
     recepta.OnBaixa();
     Assert.AreEqual(false, bdProves.CompruebaSiFunciona(ingredient.StringConsultaSql()));
 }
Exemplo n.º 5
0
		public static Ingredient[] IngredientsDessats(Gabriel.Cat.BaseDeDades baseDeDades)
		{
			List<Ingredient> ingredients = new List<Ingredient>();
			string[,] taula = baseDeDades.ConsultaTableDirect("Ingredients");
			Ingredient ingredientDessat;
			if (taula != null)
				for (int i = 1; i < taula.GetLength(1); i++) {
				ingredientDessat = new Ingredient(taula[2, i], taula[1, i], Convert.ToDecimal(taula[3, i]) / 100M);//por mirar
				if (ingredientDessat.PrimaryKey == "")
					throw new Exception("FATAL ERROR");
				ingredients.Add(ingredientDessat);
			}
			return ingredients.ToArray<Ingredient>();

		}