Exemple #1
0
 void Initialize()
 {
     string connect = @"Server = 127.0.0.1; Port = 5432; User Id = s;
         Database = practice;";
     var connection = new NpgsqlConnection(connect);
     if(connection.State == ConnectionState.Closed) {
       connection.Open();
     }
     users = new Table("users", connection);
 }
Exemple #2
0
 public Model(NpgsqlConnection connection)
 {
     if(connection.State == ConnectionState.Closed) {
         connection.Open();
     }
     users = new Table("users", connection);
     sites = new Table("sites", connection);
     subpages = new Table("subpages", connection);
     reports = new Table("reports", connection);
     rules = new Table("rules", connection);
 }
Exemple #3
0
        public void TestInsertAndSelect()
        {
            Initialize();
            name = "Vasya";
            password = "******";
            string insert = String.Format("'{0}', '{1}'", name, password);
            users.Insert(insert, "name, password").All();
            users = users.Select("*").Order("-id").All();

            Assert.IsTrue(users.data.Read(), "String was inserted");
            Assert.AreEqual(users.data.GetString(1), name, "Name is the same");
            Assert.AreEqual(users.data.GetString(2), password,
                "Password is the same");
        }