public void TestDataTypeDefinitionForInt() { //arrange var column = new DatabaseColumn { DbDataType = "int", DataType = new DataType("int", "int") }; //act var result = column.DataTypeDefinition(); //assert Assert.AreEqual("int", result); }
private static void FillColumn(TreeNode tableNode, DatabaseColumn column, int intImageIndex) { var sb = new StringBuilder(); sb.Append(column.Name); sb.Append(" "); sb.Append(column.DataTypeDefinition()); if (!column.Nullable) { sb.Append(" NOT NULL"); } if (column.IsPrimaryKey) { sb.Append(" PK"); } if (column.IsAutoNumber) { //identity or autonumber if (column.IdentityDefinition != null) { sb.Append(" Identity"); if (column.IdentityDefinition.IsNonTrivialIdentity()) { sb.Append('('); sb.Append(column.IdentityDefinition.IdentitySeed); sb.Append(','); sb.Append(column.IdentityDefinition.IdentityIncrement); sb.Append(')'); } } else { sb.Append(" AutoNumber"); } } if (column.IsForeignKey) { sb.Append(" FK to " + column.ForeignKeyTableName); } var colNode = new TreeNode(sb.ToString()); if (!(column.Table is DatabaseView)) { colNode.Tag = column; colNode.ToolTipText = RightClickToScript; colNode.ImageIndex = intImageIndex; } tableNode.Nodes.Add(colNode); }
public void TestDataTypeDefinitionForVarChar() { //arrange var column = new DatabaseColumn { DbDataType = "nvarchar", DataType = new DataType("nvarchar", "System.String"), Length = 15 }; //act var result = column.DataTypeDefinition(); //assert Assert.AreEqual("nvarchar(15)", result); }
public void TestDataTypeDefinitionForMySqlVarChar() { //arrange var column = new DatabaseColumn { DbDataType = "varchar(50)", //below will be ignored as MySql gives the full native type DataType = new DataType("VARCHAR", "System.String"), Length = 50 }; //act var result = column.DataTypeDefinition(); //assert Assert.AreEqual("varchar(50)", result); }
public void TestDataTypeDefinitionForDecimal() { //arrange var column = new DatabaseColumn { DbDataType = "decimal", DataType = new DataType("decimal", "System.Decimal"), Precision = 10, Scale = 2 }; //act var result = column.DataTypeDefinition(); //assert Assert.AreEqual("decimal(10,2)", result); }
public void TestDataTypeDefinitionForMySqlSmallInt() { //arrange var column = new DatabaseColumn { DbDataType = "smallint(5) unsigned", //below will be ignored as MySql gives the full native type DataType = new DataType("SMALLINT", "System.Int16"), Precision = 5, Scale = 0 }; //act var result = column.DataTypeDefinition(); //assert Assert.AreEqual("smallint(5) unsigned", result); }