Exemplo n.º 1
0
        public void TestString()
        {
            //arrange
            const string s = "Hello";
            const SqlType sqlType = SqlType.Db2;
            var dateTypes = new Dictionary<string, string>();

            var converter = new Converter(sqlType, dateTypes);

            //act
            var result = converter.Convert(typeof(string), s, "Name");

            //assert
            Assert.AreEqual("'Hello'", result);
        }
Exemplo n.º 2
0
        public void TestDbNull()
        {
            //arrange
            var dbNull = DBNull.Value;
            const SqlType sqlType = SqlType.Db2;
            var dateTypes = new Dictionary<string, string>();

            var converter = new Converter(sqlType, dateTypes);

            //act
            var result = converter.Convert(typeof(string), dbNull, "Name");

            //assert
            Assert.AreEqual("NULL", result);
        }
Exemplo n.º 3
0
        public void TestDate()
        {
            //arrange
            var dt = new DateTime(2001, 3, 30, 10, 45, 30, 839);
            const SqlType sqlType = SqlType.Db2;
            var dateTypes = new Dictionary<string, string>();
            dateTypes.Add("StartDate", "TIMESTAMP");

            var converter = new Converter(sqlType, dateTypes);

            //act
            var result = converter.Convert(typeof(DateTime), dt, "StartDate");

            //assert
            Assert.AreEqual("'2001-03-30 10:45:30.839'", result);
        }
Exemplo n.º 4
0
        public void TestStringTimeSpan()
        {
            //arrange
            var ts = new TimeSpan(1, 2, 3);
            const SqlType sqlType = SqlType.SqlServer;
            var dateTypes = new Dictionary<string, string>();

            var converter = new Converter(sqlType, dateTypes);

            //act
            var result = converter.Convert(typeof(TimeSpan), ts, "Name");

            //assert
            Assert.AreEqual("'01:02:03'", result);
        }
Exemplo n.º 5
0
        public void TestStringDecimal()
        {
            //arrange
            const decimal i = 10.5M;
            const SqlType sqlType = SqlType.SqlServer;
            var dateTypes = new Dictionary<string, string>();

            var converter = new Converter(sqlType, dateTypes);

            //act
            var result = converter.Convert(typeof(decimal), i, "Name");

            //assert
            Assert.AreEqual("10.5", result);
        }
Exemplo n.º 6
0
        public void TestStringInteger()
        {
            //arrange
            const int i = 10;
            const SqlType sqlType = SqlType.SqlServer;
            var dateTypes = new Dictionary<string, string>();

            var converter = new Converter(sqlType, dateTypes);

            //act
            var result = converter.Convert(typeof(int), i, "Name");

            //assert
            Assert.AreEqual("10", result);
        }