lundi 26 octobre 2015

Entity Framework Migrations Testing Migration File

I am looking into using EF Migrations for our database. I would like to create unit tests to verify that the migrations are created correctly. (Aka CreateTable("Foobar") was called.) I see that the DbMigration class inherits from IDbMigrations, CreateTable is not part of the interface.

Is there a way to verify that CreateTable(...), PrimaryKey(...), etc were called with the correct parameters?

Thanks much

Example of what i would like to test

    public override void Up()
    {
        CreateTable(
            "dbo.address_book",
            c => new
                {
                    id = c.Int(nullable: false, identity: true),
                    name = c.String(nullable: false, maxLength: 125, unicode: false),
                    description = c.String(maxLength: 255, unicode: false),
                })
            .PrimaryKey(t => t.id);
    }

Aucun commentaire:

Enregistrer un commentaire