public void DeleteTest() { using (ToLClassStatsEntities oDc = new ToLClassStatsEntities()) { tblToLClass tolC = oDc.tblToLClasses.FirstOrDefault(tc => tc.Id == 46); oDc.tblToLClasses.Remove(tolC); oDc.SaveChanges(); tblToLClass deletedClass = oDc.tblToLClasses.FirstOrDefault(tc => tc.Id == 46); Assert.IsNull(deletedClass); } }
public void UpdateTest() { using (ToLClassStatsEntities oDc = new ToLClassStatsEntities()) { tblToLClass tolC = oDc.tblToLClasses.FirstOrDefault(tc => tc.Id == 46); tolC.Name = "Updated class"; oDc.SaveChanges(); tblToLClass updatedClass = oDc.tblToLClasses.FirstOrDefault(tc => tc.Id == 46); Assert.AreEqual(updatedClass.Name, tolC.Name); } }
public void InsertTest() { using (ToLClassStatsEntities oDc = new ToLClassStatsEntities()) { tblToLClass newRow = new tblToLClass(); newRow.Name = "Test Class"; newRow.Faction = "Test Faction"; newRow.TimesPlayed = -1; oDc.tblToLClasses.Add(newRow); oDc.SaveChanges(); tblToLClass tolC = (from tc in oDc.tblToLClasses where tc.Id == 46 select tc).FirstOrDefault(); Assert.IsNotNull(tolC); } }
public void Delete() { try { using (ToLClassStatsEntities oDc = new ToLClassStatsEntities()) { tblToLClass tolClass = oDc.tblToLClasses.FirstOrDefault(tc => tc.Id == Id); oDc.tblToLClasses.Remove(tolClass); oDc.SaveChanges(); } } catch (Exception) { throw; } }
public void Update(int classId, DateTime datePlayed) { try { using (ToLClassStatsEntities oDc = new ToLClassStatsEntities()) { tblToLClass tolClass = oDc.tblToLClasses.FirstOrDefault(tc => tc.Id == Id); tolClass.Name = Name; tolClass.Faction = Faction; tolClass.TimesPlayed = TimesPlayed; oDc.SaveChanges(); } InsertDatePlayed(classId, datePlayed); } catch (Exception) { throw; } }
public void Insert() { try { using (ToLClassStatsEntities oDc = new ToLClassStatsEntities()) { tblToLClass tolClass = new tblToLClass(); tolClass.Name = Name; tolClass.Faction = Faction; tolClass.TimesPlayed = TimesPlayed; oDc.tblToLClasses.Add(tolClass); oDc.SaveChanges(); } } catch (Exception) { throw; } }