예제 #1
0
        public void TIME_HighResolution_Data_ScriptsCorrectly()
        {
            TimeSpan baseData  = new TimeSpan(TimeSpan.TicksPerHour * 2 + TimeSpan.TicksPerMinute * 33 + TimeSpan.TicksPerSecond * 44 + 1234567);
            object   data      = baseData;
            var      fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "time", false, 0, 0);

            Assert.AreEqual("'02:33:44.1234567'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "time fractional seconds");
            Assert.AreEqual("02:33:44.1234567", FieldScripting.formatTime(data, false), "time fractional seconds");
        }
예제 #2
0
        public void SQLVARIANT_Bit_Data_ScriptsCorrectly()
        {
            bool   baseData = false;
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 0, 0);

            Assert.AreEqual("0", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant");
        }
예제 #3
0
        public void SQLVARIANT_DateTimeOffset_Data_ScriptsCorrectly()
        {
            DateTimeOffset baseData = new DateTimeOffset(new DateTime(2014, 5, 30), new TimeSpan(1, 0, 0));
            object         data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 0, 0);

            Assert.AreEqual("'2014-05-30T00:00:00+01:00'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant");
        }
예제 #4
0
        public void DATE_Data_ScriptsCorrectly()
        {
            DateTime baseData  = new DateTime(2000, 10, 31);
            object   data      = baseData;
            var      fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "date", false, 0, 0);

            Assert.AreEqual("'2000-10-31'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "date");
            Assert.AreEqual("2000-10-31", FieldScripting.formatDate(data, false), "date");
        }
예제 #5
0
        public void SQLVARIANT_Guid_Data_ScriptsCorrectly()
        {
            Guid   baseData = new Guid("9631B0CA-D86F-4CA2-BFA5-93A9980D050A");
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 0, 0);

            Assert.AreEqual("'9631B0CA-D86F-4CA2-BFA5-93A9980D050A'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant");
        }
예제 #6
0
        public void UNIQUEIDENTIFIER_Data_ScriptsCorrectly()
        {
            Guid   baseData = new Guid("9631B0CA-D86F-4CA2-BFA5-93A9980D050A");
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "uniqueidentifier", false, 0, 0);

            Assert.AreEqual("'9631B0CA-D86F-4CA2-BFA5-93A9980D050A'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "uniqueidentifier");
            Assert.AreEqual("9631B0CA-D86F-4CA2-BFA5-93A9980D050A", FieldScripting.formatGuid(data, false), "uniqueidentifier");
        }
예제 #7
0
        public void SQLVARIANT_Binary_Data_ScriptsCorrectly()
        {
            Int32 baseData = 123456;

            byte[] data = BitConverter.GetBytes(baseData);
            EnsureByteArrayIsBigEndianLikeSQLServer(data);

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 20, "sql_variant", false, 0, 0);

            Assert.AreEqual("0x0001E240", FieldScripting.valueAsTSQLLiteral((object)data, fieldInfo), "sql_variant");
        }
예제 #8
0
        public void String_IncludingHighChar_ScriptsCorrectly()
        {
            var highChar = new char[] { '\0', '†', 'B', 'C' };

            string baseData = new string(highChar);
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "nvarchar", false, 0, 0);

            Assert.AreEqual("0x00864243", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "nvarchar");
        }
예제 #9
0
        public void TIMESTAMP_Data_ScriptsCorrectly()
        {
            Int32 baseData = 123456;

            byte[] data = BitConverter.GetBytes(baseData);
            EnsureByteArrayIsBigEndianLikeSQLServer(data);

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 8, "timestamp", false, 0, 0);

            Assert.AreEqual("0x000000000001E240", FieldScripting.valueAsTSQLLiteral((object)data, fieldInfo), "timestamp");
            Assert.AreEqual("0x000000000001E240", FieldScripting.formatTimestamp((object)data), "timestamp");
        }
예제 #10
0
        public void BIT_Data_ScriptsCorrectly()
        {
            bool   baseData  = true;
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 1, "bit", false, 0, 0);

            Assert.AreEqual("1", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "true should script as 1");

            baseData  = false;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 1, "bit", false, 0, 0);
            Assert.AreEqual("0", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "false should script as 0");
        }
예제 #11
0
        public void BIGINT_Data_ScriptsCorrectly()
        {
            Int64  baseData  = 999999999999;
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "bigint", false, 0, 0);

            Assert.AreEqual("999999999999", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "positive bigint");

            baseData  = -999999999999;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "bigint", false, 0, 0);
            Assert.AreEqual("-999999999999", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "negative bigint");
        }
예제 #12
0
        public void INT_Data_ScriptsCorrectly()
        {
            Int32  baseData  = 2000123456;
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "int", false, 0, 0);

            Assert.AreEqual("2000123456", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "positive int");

            baseData  = -2000123456;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "int", false, 0, 0);
            Assert.AreEqual("-2000123456", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "negative int");
        }
예제 #13
0
        public void TINYINT_Data_ScriptsCorrectly()
        {
            sbyte  baseData  = 125;
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 8, "tinyint", false, 0, 0);

            Assert.AreEqual("125", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "positive tinyint");

            baseData  = -125;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 8, "tinyint", false, 0, 0);
            Assert.AreEqual("-125", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "negative tinyint");
        }
예제 #14
0
        public void SMALLINT_Data_ScriptsCorrectly()
        {
            Int16  baseData  = 31000;
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 16, "smallint", false, 0, 0);

            Assert.AreEqual("31000", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "positive smallint");

            baseData  = -31000;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 16, "smallint", false, 0, 0);
            Assert.AreEqual("-31000", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "negative smallint");
        }
예제 #15
0
        public void SQLVARIANT_String_Data_ScriptsCorrectly()
        {
            string baseData = "sql variant test";
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 0, 0);

            Assert.AreEqual("N'sql variant test'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant");

            baseData  = "That's fun!    ";
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 0, 0);
            Assert.AreEqual("N'That''s fun!    '", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant escapes string fields");
        }
예제 #16
0
        public void VARBINARY_Data_ScriptsCorrectly()
        {
            Int32     baseData   = 123456;
            const int columnSize = 20;

            byte[] data = BitConverter.GetBytes(baseData);
            EnsureByteArrayIsBigEndianLikeSQLServer(data);

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", columnSize, "varbinary", false, 0, 0);

            Assert.AreEqual("0x0001E240", FieldScripting.valueAsTSQLLiteral((object)data, fieldInfo), "varbinary");

            Assert.AreEqual("0x0001E240", FieldScripting.formatVarbinary((object)data), "varbinary");
        }
예제 #17
0
        public void SMALLDATETIME_Data_ScriptsCorrectly()
        {
            DateTime baseData  = new DateTime(2000, 10, 31, 2, 33, 0);
            object   data      = baseData;
            var      fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "smalldatetime", false, 0, 0);

            Assert.AreEqual("'2000-10-31T02:33:00'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "smalldatetime");
            Assert.AreEqual("2000-10-31T02:33:00", FieldScripting.formatSmallDateTime(data, false), "smalldatetime");

            baseData = new DateTime(2000, 10, 31, 0, 0, 0);
            data     = baseData;
            Assert.AreEqual("'2000-10-31'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "midnight omits time altogether");
            Assert.AreEqual("2000-10-31", FieldScripting.formatSmallDateTime(data, false), "midnight omits time altogether");
        }
예제 #18
0
        public void DATETIMEOFFSET_Data_ScriptsCorrectly()
        {
            DateTimeOffset baseData  = new DateTimeOffset(2000, 10, 31, 2, 33, 44, new TimeSpan(3, 0, 0));
            object         data      = baseData;
            var            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "datetimeoffset", false, 0, 0);

            Assert.AreEqual("'2000-10-31T02:33:44+03:00'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "datetimeoffset no fractional seconds");
            Assert.AreEqual("2000-10-31T02:33:44+03:00", FieldScripting.formatDatetimeoffset(data, false), "datetimeoffset no fractional seconds");

            baseData = baseData.AddTicks(1234567);
            data     = baseData;
            Assert.AreEqual("'2000-10-31T02:33:44.1234567+03:00'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "datetimeoffset fractional seconds");
            Assert.AreEqual("2000-10-31T02:33:44.1234567+03:00", FieldScripting.formatDatetimeoffset(data, false), "datetimeoffset fractional seconds");
        }
예제 #19
0
        public void HIERARCHYID_Data_ScriptsCorrectly()
        {
            SqlHierarchyId baseData = SqlHierarchyId.Parse("/");
            object         data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 20, "sys.junk.hierarchyid", false, 0, 0);

            Assert.AreEqual("0x", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "hierarchyid");
            Assert.AreEqual("0x", FieldScripting.formatHierarchyId(data), "hierarchyid");

            baseData  = SqlHierarchyId.Parse("/1/");
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 20, "sys.junk.hierarchyid", false, 0, 0);
            Assert.AreEqual("0x58", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "hierarchyid");
            Assert.AreEqual("0x58", FieldScripting.formatHierarchyId(data), "hierarchyid");
        }
예제 #20
0
        public void SQLVARIANT_DateTime_Data_ScriptsCorrectly()
        {
            DateTime baseData = new DateTime(2014, 5, 30);
            object   data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 0, 0);

            Assert.AreEqual("'2014-05-30'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant");

            baseData = new DateTime(2014, 5, 30, 1, 2, 3);
            data     = baseData;
            Assert.AreEqual("'2014-05-30T01:02:03'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant");

            baseData = baseData = new DateTime(2000, 10, 31, 2, 33, 44).AddMilliseconds(100);
            data     = baseData;
            Assert.AreEqual("'2000-10-31T02:33:44.1'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant partial fractional seconds");
        }
예제 #21
0
        public void XML_Data_ScriptsCorrectly()
        {
            string baseData = "<r><n1 myattrib=\"testattrib\">Some Data</n1></r>";
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "xml", false, 0, 0);

            Assert.AreEqual("N'<r><n1 myattrib=\"testattrib\">Some Data</n1></r>'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "xml");
            Assert.AreEqual("<r><n1 myattrib=\"testattrib\">Some Data</n1></r>", FieldScripting.formatXml(data, false), "xml");

            baseData = "<r><n1 myattrib=\"testattrib\">Some Data</n1><n2>Property escaping... that's important.</n2></r>";
            data     = baseData;

            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "xml", false, 0, 0);
            Assert.AreEqual("N'<r><n1 myattrib=\"testattrib\">Some Data</n1><n2>Property escaping... that''s important.</n2></r>'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "xml escapes quotes in strings");
            Assert.AreEqual("<r><n1 myattrib=\"testattrib\">Some Data</n1><n2>Property escaping... that's important.</n2></r>", FieldScripting.formatXml(data, false), "xml");
        }
예제 #22
0
        public void TIME_LowResolution_Data_ScriptsCorrectly()
        {
            TimeSpan baseData  = new TimeSpan(0, 2, 33, 44);
            object   data      = baseData;
            var      fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "time", false, 0, 0);

            Assert.AreEqual("'02:33:44'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "time no fractional seconds");
            Assert.AreEqual("02:33:44", FieldScripting.formatTime(data, false), "time no fractional seconds");

            baseData = new TimeSpan(0, 2, 33, 44, 100);
            data     = baseData;
            Assert.AreEqual("'02:33:44.1'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "time partial fractional seconds");
            Assert.AreEqual("02:33:44.1", FieldScripting.formatTime(data, false), "time partial fractional seconds");

            baseData = new TimeSpan(0, 2, 33, 44, 123);
            data     = baseData;
            Assert.AreEqual("'02:33:44.123'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "time fractional seconds");
            Assert.AreEqual("02:33:44.123", FieldScripting.formatTime(data, false), "time fractional seconds");
        }
예제 #23
0
        public void SQLVARIANT_Float_Data_ScriptsCorrectly()
        {
            Double baseData = 1234567.89;
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 0, 0);

            Assert.AreEqual("1234567.89", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "sql_variant");

            baseData  = 12345.0000;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 10, 4);
            Assert.AreEqual("12345", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed");

            baseData  = 12345.2000;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "sql_variant", false, 10, 4);
            Assert.AreEqual("12345.2", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed (partially significant decimal)");
        }
예제 #24
0
        public void StringDataWithNulls_ScriptsCorrectly()
        {
            var leadingNull  = new char[] { '\0', 'A', 'B', 'C' };
            var trailingNull = new char[] { 'A', 'B', 'C', '\0' };

            string baseData = new string(leadingNull);
            object data     = baseData;

            var fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "nvarchar", false, 0, 0);

            Assert.AreEqual("0x00414243", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "nvarchar");

            baseData = new string(trailingNull);
            data     = baseData;


            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "nvarchar", false, 0, 0);
            Assert.AreEqual("0x41424300", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "nvarchar");
        }
예제 #25
0
        public void TIME_HighResolution_Data_ScriptsCorrectly()
        {
            DateTime baseData  = new DateTime(1900, 1, 1, 2, 33, 44);
            object   data      = baseData;
            var      fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "time", false, 0, 0);

            Assert.AreEqual("'02:33:44'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "time no fractional seconds");
            Assert.AreEqual("02:33:44", FieldScripting.formatTime(data, false), "time no fractional seconds");

            baseData = new DateTime(1900, 1, 1, 2, 33, 44).AddMilliseconds(100);
            data     = baseData;
            Assert.AreEqual("'02:33:44.1'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "partial fractional seconds");
            Assert.AreEqual("02:33:44.1", FieldScripting.formatTime(data, false), "partial fractional seconds");

            baseData = new DateTime(1900, 1, 1, 2, 33, 44).AddTicks(1234567);
            data     = baseData;
            Assert.AreEqual("'02:33:44.1234567'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "time fractional seconds");
            Assert.AreEqual("02:33:44.1234567", FieldScripting.formatTime(data, false), "time fractional seconds");
        }
예제 #26
0
        public void NTEXT_Data_ScriptsCorrectly()
        {
            string baseData  = "hello world!";
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "ntext", false, 0, 0);

            Assert.AreEqual("N'hello world!'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "ntext");
            Assert.AreEqual("hello world!", FieldScripting.formatNtext(data, false), "ntext");

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

            baseData  = "That's fun!";
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "ntext", false, 0, 0);
            Assert.AreEqual("N'That''s fun!'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "nvarchar escapes quotes in strings.");
            Assert.AreEqual("That's fun!", FieldScripting.formatNtext(data, false), "nvarchar does not escape quotes in strings when not scripted for SQL.");
        }
예제 #27
0
        public void NCHAR_Data_ScriptsCorrectly()
        {
            string baseData  = "hello world!   "; //extra spaces to pad to 15 characters are intentional since this is how the data comes back from SQL with the fixed-width type.
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "nchar", false, 0, 0);

            Assert.AreEqual("N'hello world!'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "nchar");
            Assert.AreEqual("hello world!", FieldScripting.formatNchar(data, false), "nchar");

            baseData  = "trailing space ";
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "nchar", false, 0, 0);
            Assert.AreEqual("N'trailing space'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "nchar trims trailing space when scripted.");
            Assert.AreEqual("trailing space", FieldScripting.formatNchar(data, false), "nchar trims trailing space when scripted.");

            baseData  = "That's fun!    ";
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 15, "nchar", false, 0, 0);
            Assert.AreEqual("N'That''s fun!'", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "nchar escapes quotes in strings.");
            Assert.AreEqual("That's fun!", FieldScripting.formatNchar(data, false), "nchar does not escape quotes in strings when not scripted for SQL.");
        }
예제 #28
0
        public void DECIMAL_Data_ScriptsCorrectly()
        {
            Decimal baseData  = 12345.6789M;
            object  data      = baseData;
            var     fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "decimal", false, 10, 4);

            Assert.AreEqual("12345.6789", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "positive decimal");

            baseData  = -12345.6789M;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "decimal", false, 10, 4);
            Assert.AreEqual("-12345.6789", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "negative decimal");

            baseData  = 12345.0000M;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "decimal", false, 10, 4);
            Assert.AreEqual("12345", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed");

            baseData  = 12345.1000M;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "decimal", false, 10, 4);
            Assert.AreEqual("12345.1", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed (partially significant decimal)");
        }
예제 #29
0
        public void REAL_Data_ScriptsCorrectly()
        {
            Single baseData  = 200.1234F;
            object data      = baseData;
            var    fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "real", false, 0, 0);

            Assert.AreEqual("200.1234", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "positive real");

            baseData  = -200.1234F;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "real", false, 0, 0);
            Assert.AreEqual("-200.1234", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "negative real");

            baseData  = 12345.0000F;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "real", false, 10, 4);
            Assert.AreEqual("12345", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed");

            baseData  = 12345.2000F;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "float", false, 10, 4);
            Assert.AreEqual("12345.2", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed (partially significant decimal)");
        }
예제 #30
0
        public void SMALLMONEY_Data_ScriptsCorrectly()
        {
            Decimal baseData  = 200000.1234M;
            object  data      = baseData;
            var     fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "smallmoney", false, 10, 4);

            Assert.AreEqual("200000.1234", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "positive smallmoney");

            baseData  = -200000.1234M;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 32, "smallmoney", false, 10, 4);
            Assert.AreEqual("-200000.1234", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "negative smallmoney");

            baseData  = 12345.0000M;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "smallmoney", false, 10, 4);
            Assert.AreEqual("12345", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed");

            baseData  = 12345.1000M;
            data      = baseData;
            fieldInfo = SchemaScriptingTests.FakeColumn("test", "test", 64, "smallmoney", false, 10, 4);
            Assert.AreEqual("12345.1", FieldScripting.valueAsTSQLLiteral(data, fieldInfo), "insignificant digits are trimmed (partially significant decimal)");
        }