public void LogToLoggingDatabase() { Data.Database loggingDb = DatabaseFactory.CreateDatabase("LoggingDb"); string sql = "delete [Log]"; DBCommandWrapper cmd = loggingDb.GetSqlStringCommandWrapper(sql); loggingDb.ExecuteNonQuery(cmd); Logger.Write("test message", "LoggingDbCategory"); sql = "select * from [Log]"; cmd = loggingDb.GetSqlStringCommandWrapper(sql); DataSet ds = loggingDb.ExecuteDataSet(cmd); Assert.AreEqual(1, ds.Tables[0].Rows.Count); }
public void SetUp() { string partitionName = "Partition1"; backingStore = CreateBackingStore(instanceName, partitionName); Data.Database db = DatabaseFactory.CreateDatabase("CachingDatabase"); DBCommandWrapper wrapper = db.GetSqlStringCommandWrapper("delete from CacheData"); db.ExecuteNonQuery(wrapper); }
public static DataTable LoadEntLibLogTable(Data.Database db) { // open the table and compare string sql = "select * from Log"; DBCommandWrapper cmd = db.GetSqlStringCommandWrapper(sql); DataSet ds = new DataSet(); db.LoadDataSet(cmd, ds, "Log"); return(ds.Tables[0]); }
private DataSet SelectIdentity() { DBCommandWrapper cmd = userDb.GetSqlStringCommandWrapper("select * from Users where UserName = @name"); cmd.AddInParameter("name", DbType.String, userName); return(userDb.ExecuteDataSet(cmd)); }
public void ItemRemovedFromCacheCompletelyIfAddFails() { cache.Add("foo", new SerializableClass()); try { cache.Add("foo", new NonSerializableClass()); Assert.Fail("should have thrown exception in Cache.Add"); } catch (Exception) { Assert.IsFalse(cache.Contains("foo")); string isItInDatabaseQuery = "select count(*) from CacheData"; Data.Database db = DatabaseFactory.CreateDatabase("CachingDatabase"); DBCommandWrapper wrapper = db.GetSqlStringCommandWrapper(isItInDatabaseQuery); int count = (int)db.ExecuteScalar(wrapper); Assert.AreEqual(0, count); } }
public static void DeleteTestData(ConfigurationContext context) { Data.Database db = DatabaseFactory.CreateDatabase("EntLibSecurity"); DBCommandWrapper cmd = db.GetSqlStringCommandWrapper("delete Profiles"); db.ExecuteNonQuery(cmd); UserRoleManager urm = new UserRoleManager("EntLibSecurity", context); try { urm.DeleteUserRole("testuser", "Users"); } catch { } try { urm.DeleteUserRole("testuser", "Managers"); } catch { } try { urm.DeleteRole("Admins"); } catch { } try { urm.DeleteRole("Managers"); } catch { } try { urm.DeleteRole("Users"); } catch { } try { urm.DeleteUser("testuser"); try { urm.DeleteUser("emptyUser"); } catch {} } catch { } try { urm.DeleteUser("bogususer"); } catch { } try { urm.DeleteUser("emptyUser"); } catch { } }