public void Define_variable_and_read_its_value() { var variables = new Variables(); variables.Set("hello", "world!"); var actualValue = variables.ReplaceVariables("%hello%"); Assert.AreEqual("world!", actualValue); }
public void Overrid_system_variables() { Prepare.WebConfig(); var variables = new Variables(); variables.Set("connection_string_name", "WiredContactDatabase"); var actualDatabase = variables.ReplaceVariables("%db%"); Assert.AreEqual("XYZ_2012_11_19", actualDatabase); }
public void Set_to_NULL() { Prepare.Database(); var variables = new Variables(); variables.Set(Variables.CONNECTION_STRING, DatabaseUtil.ConnectionString); var runner = new Runner(variables); runner.ExecScript("DummyFileName", "[database]\nCustomers[id='11111111-0000-0000-0000-000000000000'].Age = NULL"); var johnSmithAge = DatabaseUtil.Execute<object>("SELECT TOP 1 age FROM Customers WHERE name ='John Smith'"); Assert.IsTrue(Convert.IsDBNull(johnSmithAge)); }
public void Operatorless_filter() { Prepare.Database(); var variables = new Variables(); variables.Set(Variables.CONNECTION_STRING, DatabaseUtil.ConnectionString); var runner = new Runner(variables); runner.ExecScript("DummyFileName", "[database]\nCustomers['John Smith'].Age = 80"); var johnSmithAge = DatabaseUtil.Execute<int?>("SELECT TOP 1 age FROM Customers WHERE name ='John Smith'"); Assert.AreEqual(80, johnSmithAge); }
public void External_sql_file() { Prepare.Database(); Prepare.Script("setTo90.sql", "UPDATE Customers SET Age=90 WHERE Name='John Smith'"); var variables = new Variables(); variables.Set(Variables.CONNECTION_STRING, DatabaseUtil.ConnectionString); var runner = new Runner(variables); runner.ExecScript("DummyFileName", "[database]\nExec setTo90.sql"); var johnSmithAge = DatabaseUtil.Execute<int?>("SELECT TOP 1 age FROM Customers WHERE name ='John Smith'"); Assert.AreEqual(90, johnSmithAge); }
public void NotEqual_filter() { Prepare.Database(); var variables = new Variables(); variables.Set(Variables.CONNECTION_STRING, DatabaseUtil.ConnectionString); var runner = new Runner(variables); runner.ExecScript("DummyFileName", "[database]\nCustomers[id<>'11111111-0000-0000-0000-000000000000'].Age = 0"); var johnDoeAge = DatabaseUtil.Execute<int>("SELECT TOP 1 age FROM Customers WHERE name ='John Doe'"); var johnSmithAge = DatabaseUtil.Execute<int>("SELECT TOP 1 age FROM Customers WHERE name ='John Smith'"); Assert.AreEqual(0, johnDoeAge); // must be changed Assert.AreEqual(35, johnSmithAge); // must be intact }