예제 #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>();
        }
예제 #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);
     });
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
     });
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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));