public void AddModelCreatingContributor_T_T() { var context = new ScorpioDbContextOptions(); context.AddModelCreatingContributor <TestDbContext, DataModelCreatingContributor>(); context.GetModelCreatingContributors(typeof(ScorpioDbContext)).ShouldBeEmpty(); context.GetModelCreatingContributors(typeof(TestDbContext)).ShouldHaveSingleItem().ShouldBeOfType <DataModelCreatingContributor>(); }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <param name="sqlServerOptionsAction"></param> public static void UseSqlServer( [NotNull] this ScorpioDbContextOptions options, [CanBeNull] Action <SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null) { options.Configure(context => { context.UseSqlServer(sqlServerOptionsAction); }); }
public void Configure() { var context = new ScorpioDbContextOptions(); var action = Substitute.For <Action <DbContextConfigurationContext> >(); context.Configure(action); context.DefaultConfigureAction.Invoke(null); action.ReceivedWithAnyArgs(1).Invoke(null); }
public void AddModelCreatingContributor_T() { var context = new ScorpioDbContextOptions(); var contributor = Substitute.For <IModelCreatingContributor>(); context.AddModelCreatingContributor <TestDbContext>(contributor); context.GetModelCreatingContributors(typeof(ScorpioDbContext)).ShouldBeEmpty(); context.GetModelCreatingContributors(typeof(TestDbContext)).ShouldHaveSingleItem().ShouldBe(contributor); }
public void PreConfigure() { var context = new ScorpioDbContextOptions(); var action = Substitute.For <Action <DbContextConfigurationContext> >(); context.PreConfigure(action); context.DefaultPreConfigureActions.ShouldHaveSingleItem().Invoke(null); action.ReceivedWithAnyArgs(1).Invoke(null); }
/// <summary> /// /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="options"></param> /// <param name="sqlServerOptionsAction"></param> public static void UseSqlServer <TDbContext>( this ScorpioDbContextOptions options, Action <SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null) where TDbContext : ScorpioDbContext <TDbContext> { options.Configure <TDbContext>(context => { context.UseSqlServer(sqlServerOptionsAction); }); }
public void UseSqlServer() { var context = new DbContextConfigurationContext("DefaultContext", null, null); var options = new ScorpioDbContextOptions(); options.UseSqlServer(b => { }); context.DbContextOptions.Options.Extensions.Count().ShouldBe(0); options.DefaultConfigureAction.Invoke(context); context.DbContextOptions.Options.Extensions.Count().ShouldBe(2); }
public void UseSqlServer_T() { var context = new DbContextConfigurationContext <TestDbContext>("DefaultContext", null, null); var options = new ScorpioDbContextOptions(); options.UseSqlServer <TestDbContext>(b => { }); context.DbContextOptions.Options.Extensions.Count().ShouldBe(0); options.ConfigureActions[typeof(TestDbContext)].ShouldBeOfType <Action <DbContextConfigurationContext <TestDbContext> > >().Invoke(context); context.DbContextOptions.Options.Extensions.Count().ShouldBe(2); }
public void Configure_T() { var context = new ScorpioDbContextOptions(); var action = Substitute.For <Action <DbContextConfigurationContext <TestDbContext> > >(); context.Configure(action); context.ConfigureActions .ShouldHaveSingleItem() .Action(kv => kv.Key.ShouldBe(typeof(TestDbContext))) .Value.ShouldBeOfType <Action <DbContextConfigurationContext <TestDbContext> > >().Invoke(null); action.ReceivedWithAnyArgs(1).Invoke(null); }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <param name="sqlServerOptionsAction"></param> public static void UseSqlServer( this ScorpioDbContextOptions options, Action <SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null) => options.Configure(context => context.UseSqlServer(sqlServerOptionsAction));