public void Can_get_and_set_table_and_column_info()
    {
        Func <ColumnBuilder, ColumnModel> action = c => c.Decimal(name: "T");

        var addColumnOperation = new AddColumnIfNotExistsOperation("T", "C", action, null);

        Assert.AreEqual("T", addColumnOperation.Table);
        Assert.AreEqual("C", addColumnOperation.Name);
    }
    public void Inverse_should_produce_drop_column_operation()
    {
        Func <ColumnBuilder, ColumnModel> action = c => c.Decimal(name: "C", annotations: new Dictionary <string, AnnotationValues> {
            { "A1", new AnnotationValues(null, "V1") }
        });

        var addColumnOperation = new AddColumnIfNotExistsOperation("T", "C", action, null);

        var dropColumnOperation = (DropColumnOperation)addColumnOperation.Inverse;

        Assert.AreEqual("C", dropColumnOperation.Name);
        Assert.AreEqual("T", dropColumnOperation.Table);
        Assert.AreEqual("V1", ((AnnotationValues)dropColumnOperation.RemovedAnnotations["A1"]).NewValue);
        Assert.IsNull(((AnnotationValues)dropColumnOperation.RemovedAnnotations["A1"]).OldValue);
    }
    public void AddColumnIfNotExistsSqlGenerator_Generate_can_output_add_column_statement_for_GUID_and_uses_newid()
    {
        var migrationSqlGenerator = new AddColumnIfNotExistsSqlGenerator();


        Func <ColumnBuilder, ColumnModel> action = c => c.Guid(nullable: false, identity: true, name: "Bar");


        var addColumnOperation = new AddColumnIfNotExistsOperation("Foo", "bar", action, null);

        var sql = string.Join(Environment.NewLine, migrationSqlGenerator.Generate(new[] { addColumnOperation }, "2005")
                              .Select(s => s.Sql));


        Assert.IsTrue(sql.Contains("IF NOT EXISTS(SELECT 1 FROM sys.columns"));
        Assert.IsTrue(sql.Contains("WHERE Name = N\'bar\' AND Object_ID = Object_ID(N\'[Foo]\'))"));
        Assert.IsTrue(sql.Contains("BEGIN"));
        Assert.IsTrue(sql.Contains("ALTER TABLE"));
        Assert.IsTrue(sql.Contains("[Foo]"));
        Assert.IsTrue(sql.Contains("ADD [bar] [uniqueidentifier] NOT NULL DEFAULT newsequentialid()END"));
    }