public ControllerFixture()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(GetFullPathToTestConfigFile())
                          .AddJsonFile(configFileName, optional: false, reloadOnChange: true);

            Configuration = builder.Build();

            var optionsBuilder = new DbContextOptionsBuilder <EFCoreSpikeContext>();

            optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
            Context = new EFCoreSpikeContext(optionsBuilder.Options);

            Server = new TestServer(new WebHostBuilder()
                                    .ConfigureServices(services => services.AddAutofac())
                                    .UseConfiguration(Configuration)
                                    .UseStartup <Startup>())
            {
                BaseAddress = new Uri("https://localhost/")
            };

            var getTokenTask = GetAuthorizationToken();

            AuthenticationToken = getTokenTask.Result.AccessToken;
        }
 public static void Initialize(IApplicationBuilder app)
 {
     using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
     {
         context = serviceScope.ServiceProvider.GetRequiredService <EFCoreSpikeContext>();
         context.Database.Migrate();
         InitilizeDatabase();
     }
 }
Esempio n. 3
0
 public CourseRepository(EFCoreSpikeContext context) : base(context)
 {
 }
 public EntityBaseRepository(EFCoreSpikeContext context)
 {
     this.context = context;
 }
Esempio n. 5
0
 public StudentRepository(EFCoreSpikeContext context) : base(context)
 {
 }
Esempio n. 6
0
 public BaseRepository(EFCoreSpikeContext context)
 {
     Context = context;
 }