public void CreateProductColorTest() { Random rand = new Random(); string ProductColor_name = "Diarrhea Green " + rand.Next(10000); // TODO: Initialize to an appropriate value List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value int actual; actual = DALProductColor.CreateProductColor(ProductColor_name, ref errors); ProductColorInfo pi = DALProductColor.ReadProductColorDetail(actual, ref errors); Assert.AreEqual(pi.product_color_name, ProductColor_name); Assert.AreEqual(pi.product_color_id, actual); }
public void UpdateProductColorTest() { Random rand = new Random(); String updateString = "Hello Kitty Pink " + rand.Next(1000); List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value int result = BLProductColor.UpdateProductColor(1, updateString, ref errors); AsynchLog.LogNow(errors); ProductColorInfo ProductColor = BLProductColor.ReadProductColor(1, ref errors); AsynchLog.LogNow(errors); Assert.AreEqual(1, result); Assert.AreEqual(ProductColor.product_color_id, 1); Assert.AreEqual(ProductColor.product_color_name, updateString); }
public void UpdateProductColorTest() { int myId = 1; Random rand = new Random(); ProductColorInfo Color = new ProductColorInfo(myId, "Sanrio Pink " + rand.Next(10000)); List <string> errors = new List <string>(); int result = DALProductColor.UpdateProductColor(Color.product_color_id, Color.product_color_name, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreNotEqual(-1, result); ProductColorInfo verifyColor = DALProductColor.ReadProductColorDetail(myId, ref errors); Assert.AreEqual(0, errors.Count); Assert.AreEqual(Color.product_color_id, verifyColor.product_color_id); Assert.AreEqual(Color.product_color_name, verifyColor.product_color_name); }
public static List <ProductColorInfo> ReadProductColorList(ref List <string> errors) { SqlConnection conn = new SqlConnection(connection_string); ProductColorInfo ProductColor = null; List <ProductColorInfo> ProductColorList = new List <ProductColorInfo>(); try { string strSQL = "read_all_product_color"; SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn); mySA.SelectCommand.CommandType = CommandType.StoredProcedure; DataSet myDS = new DataSet(); mySA.Fill(myDS); if (myDS.Tables[0].Rows.Count == 0) { return(null); } for (int i = 0; i < myDS.Tables[0].Rows.Count; i++) { ProductColor = new ProductColorInfo(int.Parse(myDS.Tables[0].Rows[i]["product_color_id"].ToString()), myDS.Tables[0].Rows[i]["product_color_name"].ToString()); ProductColorList.Add(ProductColor); } } catch (Exception e) { errors.Add("Error: " + e.ToString()); } finally { conn.Dispose(); conn = null; } return(ProductColorList); }
public void CreateProductColorTest() { Random rand = new Random(); String createString = "Sanrio Pink " + rand.Next(1000); List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value int result = BLProductColor.CreateProductColor(createString, ref errors); AsynchLog.LogNow(errors); Assert.AreNotEqual(result, -1); System.Diagnostics.Debug.WriteLine("RESULT:" + result); ProductColorInfo ProductColor = BLProductColor.ReadProductColor(result, ref errors); AsynchLog.LogNow(errors); System.Diagnostics.Debug.WriteLine("RESULT:" + ProductColor.product_color_id); System.Diagnostics.Debug.WriteLine("RESULT:" + ProductColor.product_color_name); Assert.AreEqual(ProductColor.product_color_id, result); Assert.AreEqual(ProductColor.product_color_name, createString); }
public static ProductColorInfo ReadProductColorDetail(int product_color_id, ref List <string> errors) { SqlConnection conn = new SqlConnection(connection_string); ProductColorInfo ProductColor = null; try { string strSQL = "read_product_color"; SqlDataAdapter mySA = new SqlDataAdapter(strSQL, conn); mySA.SelectCommand.CommandType = CommandType.StoredProcedure; mySA.SelectCommand.Parameters.Add(new SqlParameter("@product_color_id", SqlDbType.Int)); mySA.SelectCommand.Parameters["@product_color_id"].Value = product_color_id; DataSet myDS = new DataSet(); mySA.Fill(myDS); if (myDS.Tables[0].Rows.Count == 0) { return(null); } ProductColor = new ProductColorInfo(int.Parse(myDS.Tables[0].Rows[0]["product_color_id"].ToString()), myDS.Tables[0].Rows[0]["product_color_name"].ToString()); } catch (Exception e) { errors.Add("Error: " + e.ToString()); } finally { conn.Dispose(); conn = null; } return(ProductColor); }