Exemplo n.º 1
0
        public void TestGetColumn_WithBlob()
        {
            var service = this.GetService();

            var table = new CreateTableSchema("table1");

            table.AddColumn("column1", ColumnType.Blob());

            var result = service.GetColumn(table.GetColumn("column1"));

            Assert.AreEqual("[column1] VARBINARY(MAX) NOT NULL", result);
        }
Exemplo n.º 2
0
        public void TestColumnTypes()
        {
            this.BeforeEach();

            EasyMig.CreateTable("column_test")
            .AddColumn("my_char", ColumnType.Char(50))
            .AddColumn("my_varchar", ColumnType.VarChar(50))
            .AddColumn("my_text", ColumnType.Text())
            .AddColumn("my_longtext", ColumnType.LongText())
            .AddColumn("my_tiny", ColumnType.TinyInt())
            .AddColumn("my_small", ColumnType.SmallInt())
            .AddColumn("my_int", ColumnType.Int())
            .AddColumn("my_big", ColumnType.BigInt())
            .AddColumn("my_bit", ColumnType.Bit())
            .AddColumn("my_float", ColumnType.Float(2))
            .AddColumn("my_datetime", ColumnType.DateTime())
            .AddColumn("my_date", ColumnType.Date())
            .AddColumn("my_time", ColumnType.Time())
            .AddColumn("my_timestamp", ColumnType.Timestamp())
            .AddColumn("my_blob", ColumnType.Blob());

            EasyMig.ToMySql.DoMigrationsFromMemory(this.completeConnectionString);

            var result = EasyMig.Information.MySql.GetTable("db1", "column_test", this.completeConnectionString);

            Assert.AreEqual("char", (string)result.Columns["my_char"]["DATA_TYPE"]);
            Assert.AreEqual((UInt64)50, (UInt64)result.Columns["my_char"]["CHARACTER_MAXIMUM_LENGTH"]);
            Assert.AreEqual("varchar", (string)result.Columns["my_varchar"]["DATA_TYPE"]);
            Assert.AreEqual((UInt64)50, (UInt64)result.Columns["my_varchar"]["CHARACTER_MAXIMUM_LENGTH"]);
            Assert.AreEqual("text", (string)result.Columns["my_text"]["DATA_TYPE"]);
            Assert.AreEqual("longtext", (string)result.Columns["my_longtext"]["DATA_TYPE"]);
            Assert.AreEqual("tinyint", (string)result.Columns["my_tiny"]["DATA_TYPE"]);
            Assert.AreEqual("smallint", (string)result.Columns["my_small"]["DATA_TYPE"]);
            Assert.AreEqual("int", (string)result.Columns["my_int"]["DATA_TYPE"]);
            Assert.AreEqual("bigint", (string)result.Columns["my_big"]["DATA_TYPE"]);
            Assert.AreEqual("bit", (string)result.Columns["my_bit"]["DATA_TYPE"]);
            Assert.AreEqual("float", (string)result.Columns["my_float"]["DATA_TYPE"]);
            Assert.AreEqual("datetime", (string)result.Columns["my_datetime"]["DATA_TYPE"]);
            Assert.AreEqual("date", (string)result.Columns["my_date"]["DATA_TYPE"]);
            Assert.AreEqual("time", (string)result.Columns["my_time"]["DATA_TYPE"]);
            Assert.AreEqual("timestamp", (string)result.Columns["my_timestamp"]["DATA_TYPE"]);
            Assert.AreEqual("blob", (string)result.Columns["my_blob"]["DATA_TYPE"]);
        }
Exemplo n.º 3
0
        public void TestDefaultValues()
        {
            this.BeforeEach();

            EasyMig.CreateTable("column_default_values")
            .AddColumn("my_char", ColumnType.Char(50), true, "default char")
            .AddColumn("my_varchar", ColumnType.VarChar(50), true, "default varchar")
            .AddColumn("my_text", ColumnType.Text())
            .AddColumn("my_longtext", ColumnType.LongText())
            .AddColumn("my_tiny", ColumnType.TinyInt(), true, 10)     // int or string
            .AddColumn("my_small", ColumnType.SmallInt(), true, 20)
            .AddColumn("my_int", ColumnType.Int(), true, 30)
            .AddColumn("my_big", ColumnType.BigInt(), true, 40)
            .AddColumn("my_bit", ColumnType.Bit(), true, 1)                             // int
            .AddColumn("my_float", ColumnType.Float(2), true, "10.99")
            .AddColumn("my_datetime", ColumnType.DateTime(), true, "CURRENT_TIMESTAMP") // CURRENT_TIMESTAMP || NULL
            .AddColumn("my_date", ColumnType.Date())
            .AddColumn("my_time", ColumnType.Time())
            .AddColumn("my_timestamp", ColumnType.Timestamp(), true, "CURRENT_TIMESTAMP")
            .AddColumn("my_blob", ColumnType.Blob());

            EasyMig.ToMySql.DoMigrationsFromMemory(this.completeConnectionString);

            var result = EasyMig.Information.MySql.GetTable("db1", "column_default_values", this.completeConnectionString);

            Assert.AreEqual("default char", (string)result.Columns["my_char"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("default varchar", (string)result.Columns["my_varchar"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("10", (string)result.Columns["my_tiny"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("20", (string)result.Columns["my_small"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("30", (string)result.Columns["my_int"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("40", (string)result.Columns["my_big"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("b'1'", (string)result.Columns["my_bit"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("10.99", (string)result.Columns["my_float"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("CURRENT_TIMESTAMP", (string)result.Columns["my_datetime"]["COLUMN_DEFAULT"]);
            Assert.AreEqual("CURRENT_TIMESTAMP", (string)result.Columns["my_timestamp"]["COLUMN_DEFAULT"]);
        }
Exemplo n.º 4
0
        public void TestBlob()
        {
            var result = ColumnType.Blob();

            Assert.AreEqual(typeof(BlobColumnType), result.GetType());
        }