Ejemplo n.º 1
0
        public void TEXT_Data_ScriptsCorrectly()
        {
            string baseData  = "hello world!";
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "text", false, 0, 0);

            Assert.AreEqual("'hello world!'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "text");
            Assert.AreEqual("hello world!", FieldScripting.formatText(data, false), "text");

            baseData  = "trailing space ";
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "text", false, 0, 0);
            Assert.AreEqual("'trailing space '", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "text does not trim trailing space when scripted.");
            Assert.AreEqual("trailing space ", FieldScripting.formatText(data, false), "text does not trim trailing space when scripted.");

            baseData  = "That's fun!";
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "text", false, 0, 0);
            Assert.AreEqual("'That''s fun!'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "text escapes quotes in strings.");
            Assert.AreEqual("That's fun!", FieldScripting.formatText(data, false), "text does not escape quotes in strings when not scripted for SQL.");
        }