Ejemplo n.º 1
0
        public BaseTest()
        {
            var services = new ServiceCollection();

            DependencyInjectionConfig.Configure(services);
            ServiceProvider = services.BuildServiceProvider();
        }
Ejemplo n.º 2
0
        // 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);
        }
Ejemplo n.º 3
0
        // 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();
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 7
0
        // 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"
                });
            });
        }