Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void TestBuildTablesWhenTheyAlreadyExist()
        {
            //build tables
            string prefix = RandomString(10);
            SqlServerDataStoreBuilder builder = new SqlServerDataStoreBuilder(prefix, _sqlConn);
            builder.BuildDataStore();

            SqlServerDataStoreBuilder builder2 = new SqlServerDataStoreBuilder(prefix, _sqlConn);
            builder2.BuildDataStore();
        }
Ejemplo n.º 3
0
        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);
            
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        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);
        }