Ejemplo n.º 1
0
        protected TestBase()
        {
            var services = new ServiceCollection();

            services.AddDbContext <CharactersContext>(options =>
                                                      options.UseSqlite(CreateInMemoryDatabase()));
            services.AddScoped <DbContext>(provider => provider.GetService <CharactersContext>());

            Startup.AddDependencies(services);

            services.AddLogging();

            services.AddMediatR(typeof(Startup));

            Services = services.BuildServiceProvider();

            var database = Services.GetService <CharactersContext>();

            database?.Database.Migrate();
        }