public ActionResult Index() { Repo repo = new Repo(); //string result = ""; var list = repo.GetList(); DVD dvd_listDetails = list.FirstOrDefault(); //result += dvd_listDetails.Title + Environment.NewLine; //result += dvd_listDetails.Available; //result += dvd_listDetails.AverageRating; //DVD dvd_detailed = repo.FillInDetails(dvd_listDetails.dvdID); //result += dvd_detailed.MPAA; //result += dvd_detailed.Studio; //foreach (var Z in dvd_detailed.CastMembers) //{ // result += Z.CastRoleName + ": " + Z.CastFirstName + " " + Z.CastLastName + Environment.NewLine; //} //foreach (var rE in dvd_detailed.History) //{ // result += "***Records*** " + rE.Username // + " " + rE.BorrowedDate // + " " + rE.ReturnedDate // + " " + rE.DVDNote // + " " + rE.DVDRating; //} return View(list); }
public void GetList_IDMatch_Test() { Settings set = new Settings(connectionString); Repo repo = new Repo(); List<DVD> dvds = repo.GetList(); List<int> expectedIDs = new List<int>(); 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"]); } } } List<int> results = dvds.Select(d => d.dvdID).ToList(); results.Sort(); expectedIDs.Sort(); Assert.AreEqual(expectedIDs, results); }
public void Borrow_And_Return_DVDs(bool borrow) { DVD toBorrow = new DVD() { Title = "BorrowThis", CastMembers = new List<Cast>() }; Settings set = new Settings(connectionString); Repo repo = new Repo(); int newID = repo.AddDVD(toBorrow); repo.DVD_BorrowReturn(1, newID, true); List<DVD> dvds = repo.GetList(); Assert.IsTrue(!dvds.FirstOrDefault(d => d.Title == "BorrowThis" && d.dvdID == newID).Available); if (!borrow) { repo.DVD_BorrowReturn(1, newID, false); dvds = repo.GetList(); Assert.IsTrue(dvds.FirstOrDefault(d => d.Title == "BorrowThis" && d.dvdID == newID).Available); } using (SqlConnection cn = new SqlConnection(connectionString)) { DynamicParameters p = new DynamicParameters(); p.Add("dvdID", newID); cn.Query("EraseDVDRecord", p, commandType: CommandType.StoredProcedure); } }