public void TestBuildTables() { //create random prefix string prefix = RandomString(10); SqlServerDataStoreBuilder builder = new SqlServerDataStoreBuilder(prefix, _sqlConn); //call Validate() method var isValid = builder.IsDataStoreValid(); //see that it's false Assert.IsFalse(isValid); //build tables afterwards builder.BuildDataStore(); //re-validate second time isValid = builder.IsDataStoreValid(); //see that it's now true Assert.IsTrue(isValid); //test setting value to the parameter SqlServerDataStoreServices dataStoreServices = new SqlServerDataStoreServices(prefix, _sqlConn); string randomScope = RandomString(50); string randomSettingName = RandomString(50); var exists = dataStoreServices.Exists(randomScope, randomSettingName); //check that the setting exists Assert.IsFalse(exists); dataStoreServices.Create(randomScope, randomSettingName, "1", "foo"); //retrieve the value var settingValue = dataStoreServices.GetString(randomScope, randomSettingName, "1", "notfoo"); Assert.AreEqual("foo", settingValue); }
public void TestOneOverwriteAndReadBack() { //build tables string prefix = RandomString(10); SqlServerDataStoreBuilder builder = new SqlServerDataStoreBuilder(prefix, _sqlConn); builder.BuildDataStore(); //create one setting SqlServerDataStoreServices dataStoreServices = new SqlServerDataStoreServices(prefix, _sqlConn); string randomScope = RandomString(50); string randomSettingName = RandomString(50); dataStoreServices.Create(randomScope, randomSettingName, "1", "foo"); //verify initial value var value = dataStoreServices.GetString(randomScope, randomSettingName, "1", ""); Assert.AreEqual("foo", value); //change setting to something dataStoreServices.Set(randomScope, randomSettingName, "1", "notfoo"); value = dataStoreServices.GetString(randomScope, randomSettingName, "1", ""); //verify it changed Assert.AreEqual("notfoo", value); }
public void TestSetNonExistent() { //build tables string prefix = RandomString(10); SqlServerDataStoreBuilder builder = new SqlServerDataStoreBuilder(prefix, _sqlConn); builder.BuildDataStore(); //create one setting SqlServerDataStoreServices dataStoreServices = new SqlServerDataStoreServices(prefix, _sqlConn); string randomScope = RandomString(50); string randomSettingName = RandomString(50); dataStoreServices.Set(randomScope, randomSettingName, "1", "foo"); }
public void TestReadNonExistent() { //build tables string prefix = RandomString(10); SqlServerDataStoreBuilder builder = new SqlServerDataStoreBuilder(prefix, _sqlConn); builder.BuildDataStore(); //create one setting SqlServerDataStoreServices dataStoreServices = new SqlServerDataStoreServices(prefix, _sqlConn); string randomScope = RandomString(50); string randomSettingName = RandomString(50); var result = dataStoreServices.GetString(randomScope, randomSettingName, "1", "randomString"); Assert.AreEqual("randomString", result); }