Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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
        }