public BaseTest() { var services = new ServiceCollection(); DependencyInjectionConfig.Configure(services); ServiceProvider = services.BuildServiceProvider(); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { AuthenticationConfig.Configure(services, Configuration); BlazorConfig.Configure(services, Configuration); DependencyInjectionConfig.Configure(services, Configuration); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext <MyFitnessLogContext>(options => { options.UseSqlServer(Configuration["ConnectionStrings:SqlConnectionString"], actions => actions.MigrationsAssembly("MyFitnessLog.Data.Models")); }); DependencyInjectionConfig.Configure(services); }
private TestCompositionRoot(IServiceCollection services, bool useFakes) { DependencyInjectionConfig.Configure(services, new ConfigurationRoot(new List <IConfigurationProvider>())); if (useFakes) { RegisterFakes(services); } _provider = services.BuildServiceProvider(); }
private TestCompositionRoot(string databaseName, IServiceCollection services) { _inMemoryDatabaseName = databaseName; DependencyInjectionConfig.Configure(services); RegisterFunctions(services); RegisterFakes(services); _provider = services.BuildServiceProvider(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddDefaultPolicy( builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); services.AddControllers(); DependencyInjectionConfig.Configure(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddAutoMapper(typeof(Startup)); /* add datacontext here */ services.AddDbContext <SimpleInventoryDbContext>(opt => { opt.UseMySql(Configuration.GetConnectionString("ConnStr")); }); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <SimpleInventoryDbContext>() .AddDefaultTokenProviders(); services.AddAuthentication(opt => { opt.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; opt.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(opt => { opt.RequireHttpsMetadata = false; opt.SaveToken = true; opt.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = false, ValidateAudience = false, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["JWT:SigningKey"])) }; }); /* dependency injection here */ DependencyInjectionConfig.Configure(services); services.AddCors(); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "SimpleInventoryAPI", Version = "v1" }); }); }