public void TestClearSportOldSportPresent() { Int32 anID = 10; string aName = "Triathlon"; string aMemo = "Esto es un ejemplo de memo"; Sport aSport = new Sport(anID, aName, aMemo); Sport oldSport = new Sport(); Assert.AreEqual(anID, aSport.SportID); Assert.AreEqual(aName, aSport.Name); Assert.AreEqual(aMemo, aSport.Memo); Assert.AreEqual(0, oldSport.SportID); Assert.AreEqual(null, oldSport.Name); Assert.AreEqual(null, oldSport.Memo); oldSport.CopySport(aSport); Assert.AreEqual(anID, aSport.SportID); Assert.AreEqual(aName, aSport.Name); Assert.AreEqual(aMemo, aSport.Memo); Assert.AreEqual(anID, oldSport.SportID); Assert.AreEqual(aName, oldSport.Name); Assert.AreEqual(aMemo, oldSport.Memo); aSport.ClearSport(); Assert.AreEqual(0, aSport.SportID); Assert.AreEqual(null, aSport.Name); Assert.AreEqual(null, aSport.Memo); Assert.AreEqual(anID, oldSport.SportID); Assert.AreEqual(aName, oldSport.Name); Assert.AreEqual(aMemo, oldSport.Memo); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { sportUsed = new Sport(); oldSportUsed = new Sport(); using (var db = new ClubSiteContext()) { sportUsed = (from sports in db.Sports orderby sports.Name select sports).FirstOrDefault(); if (sportUsed == null) { sportUsed = new Sport(); X.Msg.Alert("Atención", "No hay ningún tipo de deporte registrado en la Base de datos.").Show(); } oldSportUsed.CopySport(sportUsed); LoadSportInForm(sportUsed); } } }