Example #1
0
 public ActionResult Edit(long id)
 {
     try
     {
         ProductInput model     = new ProductInput();
         DataSet      dsproduct = TblProduct.SelectProductByID(id);
         if (dsproduct != null && dsproduct.Tables.Count > 0 && dsproduct.Tables[0].Rows.Count > 0)
         {
             model.ProductID   = Convert.ToInt64(dsproduct.Tables[0].Rows[0]["ProductId"]);
             model.ProductName = Convert.ToString(dsproduct.Tables[0].Rows[0]["ProductName"]);
             model.Description = Convert.ToString(dsproduct.Tables[0].Rows[0]["Description"]);
             model.Price       = Convert.ToDecimal(dsproduct.Tables[0].Rows[0]["Price"]);
         }
         return(View(model));
     }
     catch (Exception)
     {
         throw new Exception();
     }
 }
Example #2
0
        public void Edit(long id)
        {
            ProductInput model     = new ProductInput();
            DataSet      dsproduct = TblProduct.SelectProductByID(id);

            //Checks for count of records
            Assert.AreNotEqual(dsproduct.Tables.Count, 0);
            Assert.AreNotEqual(dsproduct.Tables[0].Rows.Count, 0);
            //Check for columns
            Assert.AreNotEqual(dsproduct.Tables[0].Columns.Count, 0);
            Assert.AreEqual(dsproduct.Tables[0].Columns.Count, 13);
            //Check for column values types
            Assert.AreEqual(dsproduct.Tables[0].Columns["ProductId"].DataType, typeof(Int64));
            Assert.AreEqual(dsproduct.Tables[0].Columns["ProductName"].DataType, typeof(string));
            Assert.AreEqual(dsproduct.Tables[0].Columns["Description"].DataType, typeof(string));
            Assert.AreEqual(dsproduct.Tables[0].Columns["Price"].DataType, typeof(decimal));
            //Check for column value correctness
            Assert.AreNotEqual(dsproduct.Tables[0].Rows[0]["ProductId"], DBNull.Value);
            Assert.AreNotEqual(dsproduct.Tables[0].Rows[0]["ProductName"], DBNull.Value);
            Assert.AreNotEqual(dsproduct.Tables[0].Rows[0]["Description"], DBNull.Value);
            Assert.AreNotEqual(dsproduct.Tables[0].Rows[0]["Price"], DBNull.Value);
        }