Beispiel #1
0
 protected GraphUpdatesSqlServerFixtureBase()
 {
     _serviceProvider = new ServiceCollection()
                        .AddEntityFrameworkSqlServer()
                        .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                        .BuildServiceProvider();
 }
Beispiel #2
0
 public TransactionSqlServerFixture()
 {
     _serviceProvider = new ServiceCollection()
                        .AddEntityFrameworkSqlServer()
                        .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                        .BuildServiceProvider();
 }
Beispiel #3
0
        public InheritanceSqlServerFixture()
        {
            _serviceProvider
                = new ServiceCollection()
                  .AddEntityFramework()
                  .AddSqlServer()
                  .ServiceCollection()
                  .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                  .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                  .BuildServiceProvider();

            _testStore = SqlServerTestStore.CreateScratch();

            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder
            .EnableSensitiveDataLogging()
            .UseSqlServer(_testStore.Connection);

            _options = optionsBuilder.Options;
            using (var context = CreateContext())
            {
                context.Database.EnsureCreated();
                SeedData(context);
            }
        }
        public OneToOneQuerySqlServerFixture()
        {
            _serviceProvider
                = new ServiceCollection()
                  .AddEntityFramework()
                  .AddSqlServer()
                  .ServiceCollection()
                  .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                  .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                  .BuildServiceProvider();

            _testStore = SqlServerTestStore.CreateScratch();

            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseSqlServer(_testStore.ConnectionString);
            _options = optionsBuilder.Options;

            using (var context = new DbContext(_serviceProvider, _options))
            {
                context.Database.EnsureCreated();

                AddTestData(context);
            }
        }
Beispiel #5
0
 public GearsOfWarQuerySqlServerFixture()
 {
     _serviceProvider = new ServiceCollection()
                        .AddEntityFrameworkSqlServer()
                        .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                        .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                        .BuildServiceProvider();
 }
Beispiel #6
0
 public override DbContextOptions BuildOptions(IServiceCollection additionalServices = null)
 => new DbContextOptionsBuilder()
 .EnableSensitiveDataLogging()
 .UseInternalServiceProvider((additionalServices ?? new ServiceCollection())
                             .AddEntityFrameworkSqlServer()
                             .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                             .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                             .BuildServiceProvider())
 .UseSqlServer(_testStore.ConnectionString).Options;
Beispiel #7
0
 public NotificationEntitiesSqlServerFixture()
 {
     _options = new DbContextOptionsBuilder()
                .UseSqlServer(SqlServerTestStore.CreateConnectionString(DatabaseName), b => b.ApplyConfiguration())
                .UseInternalServiceProvider(new ServiceCollection()
                                            .AddEntityFrameworkSqlServer()
                                            .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                            .BuildServiceProvider())
                .Options;
 }
Beispiel #8
0
 public InheritanceRelationshipsQuerySqlServerFixture()
 {
     _serviceProvider = new ServiceCollection()
                        .AddEntityFramework()
                        .AddSqlServer()
                        .ServiceCollection()
                        .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                        .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                        .BuildServiceProvider();
 }
        public NorthwindQuerySqlServerFixture()
        {
            _serviceProvider
                = new ServiceCollection()
                  .AddEntityFrameworkSqlServer()
                  .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                  .AddSingleton <ILoggerFactory>(_testSqlLoggerFactory)
                  .BuildServiceProvider();

            _options = BuildOptions();
        }
            public NullKeysSqlServerFixture()
            {
                _options = new DbContextOptionsBuilder()
                           .UseSqlServer(SqlServerTestStore.CreateConnectionString("StringsContext"))
                           .UseInternalServiceProvider(new ServiceCollection()
                                                       .AddEntityFrameworkSqlServer()
                                                       .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                                       .BuildServiceProvider())
                           .Options;

                EnsureCreated();
            }
Beispiel #11
0
        public ComplexNavigationsQuerySqlServerFixture()
        {
            _serviceProvider = new ServiceCollection()
                               .AddEntityFrameworkSqlServer()
                               .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                               .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                               .BuildServiceProvider();

            _options = new DbContextOptionsBuilder()
                       .EnableSensitiveDataLogging()
                       .UseSqlServer(_connectionString, b => b.ApplyConfiguration())
                       .UseInternalServiceProvider(_serviceProvider).Options;
        }
            public FindSqlServerFixture()
            {
                var serviceProvider = new ServiceCollection()
                                      .AddEntityFrameworkSqlServer()
                                      .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                      .AddSingleton <ILoggerFactory, TestSqlLoggerFactory>()
                                      .BuildServiceProvider();

                _options = new DbContextOptionsBuilder()
                           .UseSqlServer(SqlServerTestStore.CreateConnectionString(DatabaseName), b => b.ApplyConfiguration())
                           .UseInternalServiceProvider(serviceProvider)
                           .EnableSensitiveDataLogging()
                           .Options;
            }
            public NullKeysSqlServerFixture()
            {
                var name             = "StringsContext";
                var connectionString = SqlServerTestStore.CreateConnectionString(name);

                _options = new DbContextOptionsBuilder()
                           .UseSqlServer(connectionString, b => b.ApplyConfiguration())
                           .UseInternalServiceProvider(new ServiceCollection()
                                                       .AddEntityFrameworkSqlServer()
                                                       .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                                       .BuildServiceProvider())
                           .Options;

                _testStore = SqlServerTestStore.GetOrCreateShared(name, EnsureCreated);
            }
            public NotificationEntitiesSqlServerFixture()
            {
                _serviceProvider = new ServiceCollection()
                                   .AddEntityFramework()
                                   .AddSqlServer()
                                   .ServiceCollection()
                                   .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                   .BuildServiceProvider();

                var optionsBuilder = new DbContextOptionsBuilder();

                optionsBuilder.UseSqlServer(SqlServerTestStore.CreateConnectionString("NotificationEntities"));
                _options = optionsBuilder.Options;

                EnsureCreated();
            }
        public NorthwindSprocQuerySqlServerFixture()
        {
            _testStore = SqlServerNorthwindContext.GetSharedStore();

            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                  .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                                  .BuildServiceProvider();

            _options = new DbContextOptionsBuilder()
                       .EnableSensitiveDataLogging()
                       .UseInternalServiceProvider(serviceProvider)
                       .UseSqlServer(_testStore.ConnectionString).Options;

            serviceProvider.GetRequiredService <ILoggerFactory>();
        }
        public BuiltInDataTypesSqlServerFixture()
        {
            _testStore = SqlServerTestStore.CreateScratch();

            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                  .BuildServiceProvider();

            _options = new DbContextOptionsBuilder()
                       .UseSqlServer(_testStore.Connection)
                       .UseInternalServiceProvider(serviceProvider)
                       .Options;

            using (var context = new DbContext(_options))
            {
                context.Database.EnsureCreated();
            }
        }
Beispiel #17
0
        public OneToOneQuerySqlServerFixture()
        {
            _testStore = SqlServerTestStore.Create("OneToOneQueryTest");

            _options = new DbContextOptionsBuilder()
                       .UseSqlServer(_testStore.ConnectionString, b => b.ApplyConfiguration())
                       .UseInternalServiceProvider(new ServiceCollection()
                                                   .AddEntityFrameworkSqlServer()
                                                   .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                                   .AddSingleton <ILoggerFactory>(new TestSqlLoggerFactory())
                                                   .BuildServiceProvider())
                       .Options;

            using (var context = new DbContext(_options))
            {
                context.Database.EnsureCreated();

                AddTestData(context);
            }
        }
Beispiel #18
0
        public BuiltInDataTypesSqlServerFixture()
        {
            _testStore = SqlServerTestStore.Create("BuiltInDataTypes");

            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .AddSingleton(TestSqlServerModelSource.GetFactory(OnModelCreating))
                                  .AddSingleton <ILoggerFactory>(_testSqlLoggerFactory)
                                  .BuildServiceProvider();

            _options = new DbContextOptionsBuilder()
                       .UseSqlServer(_testStore.Connection, b => b.ApplyConfiguration())
                       .EnableSensitiveDataLogging()
                       .UseInternalServiceProvider(serviceProvider)
                       .Options;

            using (var context = new DbContext(_options))
            {
                context.Database.EnsureCreated();
            }
        }