Beispiel #1
0
        public void DonarDeAltaUnitatProducte()
        {
            UnitatProducte unitat = new UnitatProducte(new Producte("ProvaUnitatProducte"));

            control.Afegir((ObjecteSql)unitat.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)unitat.Producte); //doy de alta el producto
            control.Afegir(unitat);                      //doy de alta la unidad
            Assert.AreEqual(true, bdProves.CompruebaSiFunciona(unitat.StringConsultaSql()));
        }
Beispiel #2
0
        public void DonarDeBaixaUnitatProducte()
        {
            UnitatProducte unitat = new UnitatProducte(new Producte("ProvaUnitatProducte2"));

            control.Afegir((ObjecteSql)unitat.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)unitat.Producte);
            control.Afegir(unitat);
            unitat.OnBaixa();
            Assert.AreEqual(false, bdProves.CompruebaSiFunciona(unitat.StringConsultaSql()));
        }
Beispiel #3
0
        public void DonarDeBaixaUnitatDonantDeBaixaElProducte()
        {
            UnitatProducte unitat = new UnitatProducte(new Producte("ProvaUnitatProducte2"));

            control.Afegir((ObjecteSql)unitat.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)unitat.Producte);
            control.Afegir(unitat);
            unitat.Producte.OnBaixa();//tiene que dar de baja todas sus unidades
            Assert.AreEqual(false, bdProves.CompruebaSiFunciona(unitat.StringConsultaSql()));
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            BaseDeDadesMySQL bd = new BaseDeDadesMySQL();

            bd.Conecta();
            ControlObjectesSql control = new Control(bd);

            var estoc = control.Restaurar();

            Estoc.Estoc estocAct = new Estoc.Estoc();
            control.Reset();
            Producte       producte = new Producte("ProvaIDProducte", "ProvaCategoria", "ProvaUnitat", new TimeSpan(4, 3, 2, 1), new TimeSpan(1, 0, 0, 0), new TimeSpan(1, 2, 3, 4), new Recepta(), 5, 100);
            UnitatProducte unitat   = new UnitatProducte(producte);
            UnitatProducte unitat2  = new UnitatProducte(producte);

            unitat2.Recepta = new Recepta("Altre");
            control.Afegir((ObjecteSql)unitat2.Recepta);
            unitat2.Recepta.Afegir(new Ingredient(producte, 100M));
            control.Afegir((IEnumerable <Ingredient>)unitat2.Recepta);
            unitat2.Quantitat = 12.3M;
            unitat.Quantitat  = 10;
            control.Afegir((ObjecteSql)producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)producte);
            control.Afegir(unitat);
            control.Afegir(unitat2);
            control.ComprovaActualitzacions();
            estocAct.Afegir(producte);
            if (estocAct.Equals(estoc))
            {
                Console.WriteLine("Funciona");                //si esta bien!!
            }
            else
            {
                Console.WriteLine("No funciona");
            }


            estoc = control.Restaurar();
            if (estocAct.Equals(estoc))
            {
                Console.WriteLine("Funciona");                //si esta bien!!
            }
            else
            {
                Console.WriteLine("No funciona");
            }
            //Console.WriteLine(unitat2);
            //Console.WriteLine(unitat2.Recepta);
            //Console.WriteLine(producte);
            //Console.WriteLine(estoc);
            //Console.WriteLine(control);
            Console.ReadKey();
        }
Beispiel #5
0
        public void ErrorFabricaProductesInsuficients()
        {
            Producte       pa             = new Producte("Pa");
            Producte       formatge       = new Producte("Formatge");
            Recepta        receptaBocata  = new Recepta("BocataFormatge");
            Producte       bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa       = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);
            UnitatProducte unitatBocata;

            Estoc.Estoc estoc = new Estoc.Estoc();
            receptaBocata.Afegir(new Ingredient(pa, 1.5M));
            receptaBocata.Afegir(new Ingredient(formatge, 50));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatBocata = Producte.Fabrica(bocataFormatge, receptaBocata, new Producte[] { pa, formatge });//por cambiar...se tiene que hacer...
            Assert.AreEqual(null, unitatBocata);
        }
Beispiel #6
0
        public void FabricaElMaximDeProducteAmbProductesDeEstoc()
        {
            Producte       pa             = new Producte("Pa");
            Producte       formatge       = new Producte("Formatge");
            Recepta        receptaBocata  = new Recepta("BocataFormatge");
            Producte       bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa       = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);

            UnitatProducte[] unitatsBocata;
            Estoc.Estoc      estoc = new Estoc.Estoc();
            receptaBocata.Afegir(new Ingredient(pa, 1.5M));
            receptaBocata.Afegir(new Ingredient(formatge, 6));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatsBocata = Producte.FabricaElMax(bocataFormatge, estoc, receptaBocata);
            Assert.AreNotEqual(new UnitatProducte[] {}, unitatsBocata);
        }
Beispiel #7
0
        public void FabricaProducteAmbReceptaOriginal()
        {
            Producte       pa             = new Producte("Pa");
            Producte       formatge       = new Producte("Formatge");
            Recepta        receptaBocata  = new Recepta("BocataFormatge");
            Producte       bocataFormatge = new Producte("Bocata de Formatge");
            UnitatProducte unitatPa       = new UnitatProducte(pa, 10);
            UnitatProducte unitatFormatge = new UnitatProducte(formatge, 15);
            UnitatProducte unitatBocata;

            Estoc.Estoc estoc = new Estoc.Estoc();
            bocataFormatge.ReceptaOriginal = receptaBocata;
            receptaBocata.Afegir(new Ingredient(pa, 1));
            receptaBocata.Afegir(new Ingredient(formatge, 4));
            estoc.Afegir(new Producte[] { pa, formatge, bocataFormatge });
            unitatBocata = Producte.Fabrica(bocataFormatge, estoc);
            Assert.AreNotEqual(null, unitatBocata);
        }
Beispiel #8
0
        public void ActualitzarDadesUnitatProducte()
        {
            UnitatProducte unitat = new UnitatProducte(new Producte("ProvaUnitatProducte2"));

            control.Afegir((ObjecteSql)unitat.Producte.ReceptaOriginal);
            control.Afegir((ObjecteSql)unitat.Producte);
            control.Afegir(unitat);
            unitat.Quantitat = 223;
            control.ComprovaActualitzacions(unitat);
            UnitatProducte unitatDessada = null;
            SortedList <string, UnitatProducte> indexProductes = new SortedList <string, UnitatProducte>();

            foreach (UnitatProducte producteD in UnitatProducte.UnitatsDessades(bdProves))
            {
                indexProductes.Add(producteD.PrimaryKey, producteD);
            }
            try
            {
                unitatDessada = indexProductes[unitat.PrimaryKey];
            }
            catch { unitatDessada = new UnitatProducte(new Producte("ProvaUnitatProducte2")); }
            Assert.AreEqual(unitat.Quantitat, unitatDessada.Quantitat);//si esta bien!!
        }