public void SelectAllFailConn() { setFailConn(); ACAD food = new CADFood("GebatDataConnectionString"); food.SelectAll(); }
private ENFood() : base() { cad = new CADFood("GebatDataConnectionString"); name = ""; quantity = 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"]); } }
public void InsertNullRow() { ACAD food = new CADFood("GebatDataConnectionString"); DataRow ins = null; food.Insert(ins); }
public void TestLastConnFail() { setFailConn(); ACAD food = new CADFood("GebatDataConnectionString"); food.Last(); }
public void UpdateNullRow() { ACAD food = new CADFood("GebatDataConnectionString"); DataRow mod = null; food.Update(mod); }
public void TestCount() { int expected = 3; ACAD food = new CADFood("GebatDataConnectionString"); int actual = food.Count(); Assert.AreEqual(expected, actual); }
public void SelectWhereFailConn() { setFailConn(); ACAD food = new CADFood("GebatDataConnectionString"); food.SelectWhere("Name = 'Patates'"); }
public void DeleteWrongRow() { ACAD food = new CADFood("GebatDataConnectionString"); DataRow del = food.GetVoidRow; del["Name"] = 4; del["Quantity"] = "hola"; food.Delete(del); }
public void InsertWrongRow() { ACAD food = new CADFood("GebatDataConnectionString"); DataRow ins = food.GetVoidRow; ins["Name"] = 4; ins["Quantity"] = "hola"; food.Insert(ins); }
public void Update() { ACAD food = new CADFood("GebatDataConnectionString"); DataRow mod = food.GetVoidRow; mod["Id"] = 1; mod["Name"] = "Peres"; mod["Quantity"] = 4; food.Update(mod); }
public void InsertFailCOnn() { setFailConn(); ACAD food = new CADFood("GebatDataConnectionString"); DataRow ins = food.GetVoidRow; ins["Name"] = "Peres"; ins["Quantity"] = 4; food.Insert(ins); }
public void SelectInvalidNumberId() { List <object> ids = new List <object>(); ids.Add("hola"); ids.Add(3); ACAD food = new CADFood("GebatDataConnectionString"); food.Select(ids); }
public void Delete() { ACAD food = new CADFood("GebatDataConnectionString"); DataRow del = food.GetVoidRow; del["Id"] = 1; del["Name"] = "Patates"; del["Quantity"] = 2; food.Delete(del); }
public void UpdateWrongRow() { ACAD food = new CADFood("GebatDataConnectionString"); DataRow ins = food.GetVoidRow; ins["Id"] = 1; ins["Name"] = 4; ins["Quantity"] = "hola"; food.Update(ins); }
public void SelectConnFail() { setFailConn(); ACAD food = new CADFood("GebatDataConnectionString"); List <object> ids = new List <object>(); ids.Add(2); food.Select(ids); }
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); }
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); }
/// <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; }
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"]); }
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()); }
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"]); }
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"]); }
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"]); } }
public void SelectVoidList() { ACAD food = new CADFood("GebatDataConnectionString"); food.Select(null); }
public void DeleteNullRow() { ACAD food = new CADFood("GebatDataConnectionString"); food.Delete(null); }
public void SelectWhereInvalidStart() { ACAD food = new CADFood("GebatDataConnectionString"); food.SelectWhere("Name = 'Patates'", -3); }
public void SelectWjereInvalidStatement() { ACAD food = new CADFood("GebatDataConnectionString"); food.SelectWhere("Name = ; "); }