Ejemplo n.º 1
0
        public ActionResult DeleteIt(int id)
        {
            var repo = new Repo();

            repo.DeleteDVD(id);

            return RedirectToAction("Index", "Home");
        }
Ejemplo n.º 2
0
        public void DeleteDVD_Top1_DeletedDVD_DoesNotShowUpInList(int ID_to_mark)
        {
            Settings set = new Settings(connectionString);
            Repo repo = new Repo();

            List<int> expectedIDs = new List<int>();

            repo.DeleteDVD(ID_to_mark);

            using (SqlConnection cn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "SELECT * FROM DVDs WHERE Deleted IS NULL OR Deleted <> 1";
                cmd.Connection = cn;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        expectedIDs.Add((int)dr["dvdID"]);
                    }
                }
            }

            Assert.IsTrue(!expectedIDs.Contains(ID_to_mark));

            repo.RestoreDVD(ID_to_mark);
        }