Example #1
0
        public void SelectAll()
        {
            ACAD      food     = new CADType("GebatDataConnectionString");
            DataTable actual   = food.SelectAll();
            DataTable expected = this.tableFormat;
            DataRow   row      = expected.NewRow();

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

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

            row3["Id"]   = 4;
            row3["Name"] = "Paquetes";
            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"]);
            }
        }
Example #2
0
        public void TestLastConnFail()
        {
            setFailConn();
            ACAD food = new CADType("GebatDataConnectionString");

            food.Last();
        }
Example #3
0
        public void InsertNullRow()
        {
            ACAD    food = new CADType("GebatDataConnectionString");
            DataRow ins  = null;

            food.Insert(ins);
        }
Example #4
0
        public void UpdateNullRow()
        {
            ACAD    food = new CADType("GebatDataConnectionString");
            DataRow mod  = null;

            food.Update(mod);
        }
Example #5
0
        public void SelectAllFailConn()
        {
            setFailConn();
            ACAD food = new CADType("GebatDataConnectionString");

            food.SelectAll();
        }
Example #6
0
        public void TestCount()
        {
            int  expected = 3;
            ACAD food     = new CADType("GebatDataConnectionString");
            int  actual   = food.Count();

            Assert.AreEqual(expected, actual);
        }
Example #7
0
 public IModel Load(CADType c, ILoader loader)
 {
     if (_parsers.ContainsKey(c))
     {
         return _parsers[c].Parse(loader.Load());
     }
     throw new Exception("Can't parse given type.");
 }
Example #8
0
        public void DeleteWrongRow()
        {
            ACAD    food = new CADType("GebatDataConnectionString");
            DataRow del  = food.GetVoidRow;

            del["Name"] = new ENType("taca");
            food.Delete(del);
        }
Example #9
0
 public IModel Load(CADType c, ILoader loader)
 {
     if (_parsers.ContainsKey(c))
     {
         return(_parsers[c].Parse(loader.Load()));
     }
     throw new Exception("Can't parse given type.");
 }
Example #10
0
        public void SelectWhereFailConn()
        {
            setFailConn();

            ACAD food = new CADType("GebatDataConnectionString");

            food.SelectWhere("Name = 'Kg'");
        }
Example #11
0
        public void Update()
        {
            ACAD    food = new CADType("GebatDataConnectionString");
            DataRow mod  = food.GetVoidRow;

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

            ins["Name"] = "Cajas";
            food.Insert(ins);
        }
Example #13
0
 /// <summary>
 /// Inicializa el tipo con el nombre.
 /// </summary>
 /// <param name="name">Nombre del tipo.</param>
 public ENType(string name)
 {
     if (name == null)
     {
         throw new NullReferenceException("The name cannot be null");
     }
     cad       = new CADType("GebatDataConnectionString");
     this.name = name;
 }
Example #14
0
        public void Delete()
        {
            ACAD    food = new CADType("GebatDataConnectionString");
            DataRow del  = food.GetVoidRow;

            del["Id"]   = 1;
            del["Name"] = "Kg";
            food.Delete(del);
        }
Example #15
0
        public void UpdateFailConn()
        {
            setFailConn();
            ACAD    food = new CADType("GebatDataConnectionString");
            DataRow ins  = food.GetVoidRow;

            ins["Id"]   = 1;
            ins["Name"] = "Cajas";
            food.Update(ins);
        }
Example #16
0
        public void DeleteFailConn()
        {
            setFailConn();
            ACAD    food = new CADType("GebatDataConnectionString");
            DataRow del  = food.GetVoidRow;

            del["Id"]   = 1;
            del["Name"] = "cajas";
            food.Delete(del);
        }
Example #17
0
        public void SelectConnFail()
        {
            setFailConn();

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

            ids.Add(2);
            food.Select(ids);
        }
Example #18
0
        public void SelectInvalidNumberId()
        {
            List <object> ids = new List <object>();

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

            food.Select(ids);
        }
Example #19
0
        public void TestLast()
        {
            ACAD    food     = new CADType("GebatDataConnectionString");
            DataRow actual   = food.Last();
            DataRow expected = food.GetVoidRow;

            expected ["Id"]   = 4;
            expected ["Name"] = "Paquetes";
            Assert.AreEqual(expected["Id"], actual["Id"]);
            Assert.AreEqual(expected["Name"], actual["Name"]);
        }
Example #20
0
        public void TestSelectOne()
        {
            string        expected = "Kg";
            ACAD          food     = new CADType("GebatDataConnectionString");
            List <object> ids      = new List <object>();

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

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

            ins["Name"] = "Cajas";
            DataRow expected = food.GetVoidRow;

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

            Assert.AreEqual(expected["Id"], actual["Id"]);
            Assert.AreEqual(expected["Name"], actual["Name"]);
        }
Example #22
0
        public void Select()
        {
            ACAD          food = new CADType("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"] = "Kg";

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

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

            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"]);
            }
        }
Example #24
0
        public void SelectWjereInvalidStatement()
        {
            ACAD food = new CADType("GebatDataConnectionString");

            food.SelectWhere("Name = ; ");
        }
Example #25
0
        public void DeleteNullRow()
        {
            ACAD food = new CADType("GebatDataConnectionString");

            food.Delete(null);
        }
Example #26
0
        public void SelectVoidList()
        {
            ACAD food = new CADType("GebatDataConnectionString");

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

            food.SelectWhere("Name = 'Kg'", -3);
        }
Example #28
0
 private ENType()
     : base()
 {
     cad  = new CADType("GebatDataConnectionString");
     name = "";
 }