Exemplo n.º 1
0
 public void AddAndDeleteUser()
 {
     using (LinqLibraryDataContext rep = new LinqLibraryDataContext(m_ConnectionString))
     {
         rep.AddUser("unexpected", "name");
         Reader r = rep.GetReader("unexpected", "name");
         Assert.IsNotNull(r);
         rep.DeleteUser(r.reader_ID);
     }
 }
Exemplo n.º 2
0
 public void RemoveReader()
 {
     using (LinqLibraryDataContext db = new LinqLibraryDataContext(m_ConnectionString))
     {
         db.AddUser("VeryUnusualName", "VeryUnusualName");
         int    count   = db.CountReaders();
         Reader whoIsHe = db.GetReader("VeryUnusualName", "VeryUnusualName");
         db.DeleteUser(whoIsHe.reader_ID);
         Assert.AreEqual(count - 1, db.CountReaders());
     }
 }
Exemplo n.º 3
0
 public void GetReaderID()
 {
     using (LinqLibraryDataContext rep = new LinqLibraryDataContext(m_ConnectionString))
     {
         rep.AddUser("oh", "no");
         Reader oh = rep.GetReader("oh", "no");
         Reader no = rep.GetReader(oh.reader_ID);
         Assert.AreEqual(no.reader_ID, oh.reader_ID);
         Assert.AreEqual(no.reader_firstName, oh.reader_firstName);
         rep.DeleteUser(oh.reader_ID);
     }
 }
Exemplo n.º 4
0
 public bool CreateReader(string name, string surname)
 {
     using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext())
     {
         if (name == null)
         {
             return(false);
         }
         dataContext.AddUser(name, surname);
         return(true);
     }
 }
Exemplo n.º 5
0
 public bool CreateReader(Reader reader)
 {
     using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext())
     {
         if (reader != null && dataContext.GetReader(reader.reader_ID) == null)
         {
             dataContext.AddUser(reader.reader_firstName, reader.reader_surname);
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 6
0
 public void TestUpdateUser()
 {
     using (LinqLibraryDataContext rep = new LinqLibraryDataContext(m_ConnectionString))
     {
         rep.AddUser("airzile", "pods");
         Reader airZile = rep.GetReader("airzile", "pods");
         rep.UpdateUserName(airZile.reader_ID, "Stu");
         rep.UpdateUserSurname(airZile.reader_ID, "GizzardLizardWizard");
         airZile = rep.GetReader(airZile.reader_ID);
         Assert.AreEqual("Stu", airZile.reader_firstName);
         Assert.AreEqual(airZile.reader_surname, rep.GetReader(airZile.reader_ID).reader_surname);
         rep.DeleteUser(airZile.reader_ID);
     }
 }