コード例 #1
0
 public void HasTypeTest()
 {
     var map = new TypeMap();
     Assert.IsFalse(map.HasType(DbType.Int32));
     map.Put(DbType.Int32, string.Empty);
     Assert.IsTrue(map.HasType(DbType.Int32));
 }
コード例 #2
0
        public void PutAndGetDecimalByColumnTypeTest()
        {
            var map = new TypeMap();
            map.Put(DbType.Decimal, "NUMBER");
            map.Put(DbType.Decimal, 18, "NUMBER($l, $s)");

            Assert.AreEqual("NUMBER(11, 2)", map.Get(DbType.Decimal.WithSize(11, 2)));
            Assert.AreEqual("NUMBER(8, $s)", map.Get(DbType.Decimal.WithSize(8))); // will cause trouble
        }
コード例 #3
0
        public void PutAndGetDecimalTest()
        {
            var map = new TypeMap();
            map.Put(DbType.Decimal, "NUMBER");
            map.Put(DbType.Decimal, 18, "NUMBER($l, $s)");

            Assert.AreEqual("NUMBER", map.Get(DbType.Decimal));
            Assert.AreEqual("NUMBER(10, 5)", map.Get(DbType.Decimal, 10, 5));
            Assert.AreEqual("NUMBER(7, $s)", map.Get(DbType.Decimal, 7)); // will cause trouble
        }
コード例 #4
0
        public void PutAndGetByColumnTypeTest2()
        {
            var map = new TypeMap();
            map.Put(DbType.AnsiString, "VARCHAR($l)");

            Assert.AreEqual("VARCHAR($l)", map.Get(new ColumnType(DbType.AnsiString)));			// will cause trouble
            Assert.AreEqual("VARCHAR(100)", map.Get(DbType.AnsiString.WithSize(100)));
            Assert.AreEqual("VARCHAR(1000)", map.Get(DbType.AnsiString.WithSize(1000)));
            Assert.AreEqual("VARCHAR(10000)", map.Get(DbType.AnsiString.WithSize(10000)));
        }
コード例 #5
0
        public ColumnSqlBuilder(Column column, TypeMap typeMap, PropertyMap propertyMap, Func<string, string> nameConverter)
        {
            Require.IsNotNull(column, "Не задан столбец таблицы для построения SQL-выражения");
            Require.IsNotNull(typeMap, "Не задан мэппинг типов данных");
            Require.IsNotNull(propertyMap, "Не задан мэппинг свойств столбца таблицы");
            Require.IsNotNull(nameConverter, "Не задан конвертер имени столбца таблицы");

            this.column = column;
            this.typeMap = typeMap;
            this.propertyMap = propertyMap;
            this.nameConverter = nameConverter;
        }
コード例 #6
0
        public void PutAndGetTest()
        {
            var map = new TypeMap();
            map.Put(DbType.AnsiString, "TEXT");
            map.Put(DbType.AnsiString, 255, "VARCHAR($l)");
            map.Put(DbType.AnsiString, 65534, "LONGVARCHAR($l)");

            Assert.AreEqual("TEXT", map.Get(DbType.AnsiString));						// default
            Assert.AreEqual("VARCHAR(100)", map.Get(DbType.AnsiString, 100));		// 100 is in [0:255]
            Assert.AreEqual("LONGVARCHAR(1000)", map.Get(DbType.AnsiString, 1000));	// 100 is in [256:65534])
            Assert.AreEqual("TEXT", map.Get(DbType.AnsiString, 100000));				// default
        }
コード例 #7
0
        public void PutAndGetTest2()
        {
            var map = new TypeMap();
            map.Put(DbType.AnsiString, "VARCHAR($l)");

            Assert.AreEqual("VARCHAR($l)", map.Get(DbType.AnsiString));			// will cause trouble
            Assert.AreEqual("VARCHAR(100)", map.Get(DbType.AnsiString, 100));
            Assert.AreEqual("VARCHAR(1000)", map.Get(DbType.AnsiString, 1000));
            Assert.AreEqual("VARCHAR(10000)", map.Get(DbType.AnsiString, 10000));
        }
コード例 #8
0
 public void HasTypeWithLengthTest()
 {
     var map = new TypeMap();
     map.Put(DbType.Int32, 4, string.Empty);
     Assert.IsTrue(map.HasType(DbType.Int32));
 }
コード例 #9
0
 public void ReplacingWithDefaultScaleTest()
 {
     var map = new TypeMap();
     map.Put(DbType.Xml, 20, "foo($l, $s)", 5);
     Assert.AreEqual("foo(12, 7)", map.Get(DbType.Xml, 12, 7));
     Assert.AreEqual("foo(12, 5)", map.Get(DbType.Xml, 12));
 }