Esempio n. 1
0
        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>();
        }
Esempio n. 2
0
 /// <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);
     });
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 /// <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);
     });
 }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 /// <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));