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)); }
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 }
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 }
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))); }
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; }
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 }
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)); }
public void HasTypeWithLengthTest() { var map = new TypeMap(); map.Put(DbType.Int32, 4, string.Empty); Assert.IsTrue(map.HasType(DbType.Int32)); }
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)); }