sia-digital / pibox

PiBox is a service hosting framework that allows .net devs to decorate their services with behaviours or functionality (think of plugins) while only using minimal configuration.
https://sia-digital.gitbook.io/pibox/
MIT License
6 stars 3 forks source link

Add ability to ensure ef core context interface and implementation match #50

Open fb-smit opened 6 months ago

fb-smit commented 6 months ago

We should add a method in the testing project which enables to check if the interface is missing any public DbSet<> from the acutal context class.

Check could look something like this

var interfacesSets = typeof(IMyDBContext).GetProperties().Select(x => x.Name);
var implementationSets = typeof(MyDBContext)
    .GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)
    .Select(x => x.Name);
string.Join(' ', implementationSets.Except(interfacesSets)).Should().BeEmpty();

The assert statement also has the benefit of showing the actual missing DbSet<> names, so one can add them easily