public UserRepositoryTests()
        {
            var options = new DbContextOptionsBuilder <CryptowiserContext>()
                          .UseInMemoryDatabase(databaseName: "CryptowiserContext")
                          .Options;

            _cryptowiserContext = new CryptowiserContext(options);
            _target             = new UserRepository(_cryptowiserContext);
        }
Esempio n. 2
0
        public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env, CryptowiserContext cryptowiserContext)
        {
            cryptowiserContext.Database.Migrate();

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            //app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();

            // global cors policy
            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });

            Log.Information("Started Web Host");
        }
 public UserRepository(CryptowiserContext context)
 {
     _context = context;
 }