// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); RegisterDI.Register(services, Configuration); services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "Logstore API", Description = "Desafio .Net", TermsOfService = new Uri("https://example.com/terms"), Contact = new OpenApiContact { Name = "Ítalo Spedini", Email = "*****@*****.**", Url = new Uri("https://www.linkedin.com/in/italo-spedini/"), } }); }); }
public static void Initialize(TestContext context) { IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); IConfiguration configuration = configurationBuilder.Build(); Startup startup = new Startup(configuration); IServiceCollection services = new ServiceCollection(); startup.ConfigureServices(services); RegisterDI.Register(services, configuration); _clienteRepository = (IClienteRepository)services.BuildServiceProvider().GetRequiredService(typeof(IClienteRepository)); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <CilCommerceDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("LocalConnectionString"))); //var config = new AutoMapper.MapperConfiguration(a => a.CreateMap<CategoryModel, Category>()); services.AddAutoMapper(typeof(OrganizationProfile)); return(RegisterDI.Register(services)); }