Beispiel #1
0
 public BasketMiddleware(
     RequestDelegate nextRequest,
     ILogger <BasketMiddleware> logger,
     IApiErrorSettings apiErrorSettings)
 {
     _NextRequest      = nextRequest;
     _Logger           = logger;
     _ApiErrorSettings = apiErrorSettings as ApiErrorSettings ?? new ApiErrorSettings();
 }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public virtual void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            IApiErrorSettings apiErrorSettings)
        {
            app.UseMiddleware <BasketMiddleware>(apiErrorSettings);

            if (!env.IsDevelopment())
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();
        }
        public void CreateClient(
            IApiErrorSettings apiErrorSettings = null)
        {
            apiErrorSettings = apiErrorSettings ?? new ApiErrorSettings();

            _ApiFactory = new WebApplicationFactory <Startup>();

            _ApiClient = _ApiFactory.WithWebHostBuilder(
                builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                    services.AddSingleton <IApiErrorSettings>(apiErrorSettings);
                });
            })
                         .CreateClient();
        }