Alright, let me see if I can explain this right without sharing out the code I have.
Given:
public static void UpdateStuff(this MigrationBuilder builder)
{
builder.Sql($"DELETE FROM {tableAttribute.Name}")
// Do a bunch of reflection to figure out table structure
// Do a bunch of reflection to read values in a static class
// Build InsertData
builder.InsertData(
tableAttribute.Name,
columns: propertyNames,
values: permissionsData);
}
Now I need to create a XUnit test that will “run” this, and get the resulting SQL script that I will compare with another preloaded string (result.sql) and see if they match.
Then:
[Fact]
public void UpdateStuff_Returns_A_Valid_SQL()
{
var builder = new Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder(null);
builder.UpdateStuff();
// Assert results
}
Initially I thought that I could create a class that inherited from Migration just so I could instantiate it and pass the builder to Up and then somehow get the generated script out of it, but I am not sure about that.
Has anyone gone through this process and would know a little bit more about how I should go about this, I search for a little while but I can really find a good example that I could follow. Any great ideas?