Example #1
0
        public void SelectAllFailConn()
        {
            setFailConn();
            ACAD food = new CADFood("GebatDataConnectionString");

            food.SelectAll();
        }
Example #2
0
 private ENFood()
     : base()
 {
     cad      = new CADFood("GebatDataConnectionString");
     name     = "";
     quantity = 0;
 }
Example #3
0
        public void SelectAll()
        {
            ACAD      food     = new CADFood("GebatDataConnectionString");
            DataTable actual   = food.SelectAll();
            DataTable expected = this.tableFormat;
            DataRow   row      = expected.NewRow();

            row["Id"]       = 1;
            row["Name"]     = "Patates";
            row["Quantity"] = 2;
            expected.Rows.Add(row);
            DataRow row2 = expected.NewRow();

            row2["Id"]       = 2;
            row2["Name"]     = "Tomates";
            row2["Quantity"] = 3;
            expected.Rows.Add(row2);
            DataRow row3 = expected.NewRow();

            row3["Id"]       = 4;
            row3["Name"]     = "Pomes";
            row3["Quantity"] = 4;
            expected.Rows.Add(row3);
            for (int i = 0; i < expected.Rows.Count; i++)
            {
                Assert.AreEqual(expected.Rows[i]["Id"], actual.Rows[i]["Id"]);
                Assert.AreEqual(expected.Rows[i]["Name"], actual.Rows[i]["Name"]);
                Assert.AreEqual(expected.Rows[i]["Quantity"], actual.Rows[i]["Quantity"]);
            }
        }
Example #4
0
        public void InsertNullRow()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow ins  = null;

            food.Insert(ins);
        }
Example #5
0
        public void TestLastConnFail()
        {
            setFailConn();
            ACAD food = new CADFood("GebatDataConnectionString");

            food.Last();
        }
Example #6
0
        public void UpdateNullRow()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow mod  = null;

            food.Update(mod);
        }
Example #7
0
        public void TestCount()
        {
            int  expected = 3;
            ACAD food     = new CADFood("GebatDataConnectionString");
            int  actual   = food.Count();

            Assert.AreEqual(expected, actual);
        }
Example #8
0
        public void SelectWhereFailConn()
        {
            setFailConn();

            ACAD food = new CADFood("GebatDataConnectionString");

            food.SelectWhere("Name = 'Patates'");
        }
Example #9
0
        public void DeleteWrongRow()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow del  = food.GetVoidRow;

            del["Name"]     = 4;
            del["Quantity"] = "hola";
            food.Delete(del);
        }
Example #10
0
        public void InsertWrongRow()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow ins  = food.GetVoidRow;

            ins["Name"]     = 4;
            ins["Quantity"] = "hola";
            food.Insert(ins);
        }
Example #11
0
        public void Update()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow mod  = food.GetVoidRow;

            mod["Id"]       = 1;
            mod["Name"]     = "Peres";
            mod["Quantity"] = 4;
            food.Update(mod);
        }
Example #12
0
        public void InsertFailCOnn()
        {
            setFailConn();
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow ins  = food.GetVoidRow;

            ins["Name"]     = "Peres";
            ins["Quantity"] = 4;
            food.Insert(ins);
        }
Example #13
0
        public void SelectInvalidNumberId()
        {
            List <object> ids = new List <object>();

            ids.Add("hola");
            ids.Add(3);
            ACAD food = new CADFood("GebatDataConnectionString");

            food.Select(ids);
        }
Example #14
0
        public void Delete()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow del  = food.GetVoidRow;

            del["Id"]       = 1;
            del["Name"]     = "Patates";
            del["Quantity"] = 2;
            food.Delete(del);
        }
Example #15
0
        public void UpdateWrongRow()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow ins  = food.GetVoidRow;

            ins["Id"]       = 1;
            ins["Name"]     = 4;
            ins["Quantity"] = "hola";
            food.Update(ins);
        }
Example #16
0
        public void SelectConnFail()
        {
            setFailConn();

            ACAD          food = new CADFood("GebatDataConnectionString");
            List <object> ids  = new List <object>();

            ids.Add(2);
            food.Select(ids);
        }
Example #17
0
        public void TestSelectOne()
        {
            string        expected = "Patates";
            ACAD          food     = new CADFood("GebatDataConnectionString");
            List <object> ids      = new List <object>();

            ids.Add((int)1);
            DataRow actual = food.Select(ids);

            Assert.AreEqual(actual["Name"].ToString(), expected);
        }
Example #18
0
        public void UpdateFailConn()
        {
            setFailConn();
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow ins  = food.GetVoidRow;

            ins["Id"]       = 1;
            ins["Name"]     = "Peres";
            ins["Quantity"] = 4;
            food.Update(ins);
        }
Example #19
0
 /// <summary>
 /// Constructor que inicializa el objeto.
 /// </summary>
 /// <param name="name">Nombre del alimento.</param>
 /// <param name="quantity">Cantidad del alimento.</param>
 public ENFood(string name, int quantity = 0, ENType type = null)
     : base()
 {
     if (name == null)
     {
         throw new NullReferenceException("The name cannot be null");
     }
     cad           = new CADFood("GebatDataConnectionString");
     this.name     = name;
     this.quantity = quantity;
     this.type     = type;
 }
Example #20
0
        public void TestLast()
        {
            ACAD    food     = new CADFood("GebatDataConnectionString");
            DataRow actual   = food.Last();
            DataRow expected = food.GetVoidRow;

            expected ["Id"]       = 4;
            expected ["Name"]     = "Pomes";
            expected ["Quantity"] = 4;
            Assert.AreEqual(expected["Id"], actual["Id"]);
            Assert.AreEqual(expected["Name"], actual["Name"]);
            Assert.AreEqual(expected["Quantity"], actual["Quantity"]);
        }
Example #21
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Escribe la contraseƱa de la base de datos.");
            ACAD.Password = Console.ReadLine();

            /*ENFood food = new ENFood ("Patates", 2);
             * Console.WriteLine ("Antes de guardar " + food.Id [0]);
             * food.Save ();
             * Console.WriteLine ("Despues de guardar " + food.Id [0]);*/
            ACAD food = new CADFood("GebatDataConnectionString");

            Console.WriteLine("Hay " + food.Count());
        }
Example #22
0
        public void Select()
        {
            ACAD          food = new CADFood("GebatDataConnectionString");
            List <object> ids  = new List <object>();

            ids.Add(1);
            DataRow   actual   = food.Select(ids);
            DataTable table    = tableFormat;
            DataRow   expected = table.NewRow();

            expected["Id"]       = 1;
            expected["Name"]     = "Patates";
            expected["Quantity"] = 2;

            Assert.AreEqual(expected["Id"], actual["Id"]);
            Assert.AreEqual(expected["Name"], actual["Name"]);
            Assert.AreEqual(expected["Quantity"], actual["Quantity"]);
        }
Example #23
0
        public void Insert()
        {
            ACAD    food = new CADFood("GebatDataConnectionString");
            DataRow ins  = food.GetVoidRow;

            ins["Name"]     = "Peres";
            ins["Quantity"] = 4;
            DataRow expected = food.GetVoidRow;

            expected ["Id"]       = 5;
            expected ["Name"]     = "Peres";
            expected ["Quantity"] = 4;
            DataRow actual = food.Insert(ins);

            Assert.AreEqual(expected["Id"], actual["Id"]);
            Assert.AreEqual(expected["Name"], actual["Name"]);
            Assert.AreEqual(expected["Quantity"], actual["Quantity"]);
        }
Example #24
0
        public void SelectWhere()
        {
            ACAD      food     = new CADFood("GebatDataConnectionString");
            DataTable expected = tableFormat;
            DataRow   row      = expected.NewRow();

            row["Id"]       = 1;
            row["Name"]     = "Patates";
            row["Quantity"] = 2;
            expected.Rows.Add(row);
            DataTable actual = food.SelectWhere("Name = 'Patates'");

            for (int i = 0; i < expected.Rows.Count; i++)
            {
                Assert.AreEqual(expected.Rows[i]["Id"], actual.Rows[i]["Id"]);
                Assert.AreEqual(expected.Rows[i]["Name"], actual.Rows[i]["Name"]);
                Assert.AreEqual(expected.Rows[i]["Quantity"], actual.Rows[i]["Quantity"]);
            }
        }
Example #25
0
        public void SelectVoidList()
        {
            ACAD food = new CADFood("GebatDataConnectionString");

            food.Select(null);
        }
Example #26
0
        public void DeleteNullRow()
        {
            ACAD food = new CADFood("GebatDataConnectionString");

            food.Delete(null);
        }
Example #27
0
        public void SelectWhereInvalidStart()
        {
            ACAD food = new CADFood("GebatDataConnectionString");

            food.SelectWhere("Name = 'Patates'", -3);
        }
Example #28
0
        public void SelectWjereInvalidStatement()
        {
            ACAD food = new CADFood("GebatDataConnectionString");

            food.SelectWhere("Name = ; ");
        }