예제 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            ValidatorOptions.Global.CascadeMode = CascadeMode.Continue;

            ConfigureAuthentication(services);

            services.AddControllers();

            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(ValidateModelStateAttribute));
            })
            .AddFluentValidation(options =>
            {
                options.RegisterValidatorsFromAssemblyContaining <Startup>();
            })
            .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
            .AddDataAnnotationsLocalization();

            services.AddLocalization(options => options.ResourcesPath = @"Resources");
            services.AddHealthChecks();

            ConfigureSwagger(services);
            ConfigureApiVersioning(services);

            DependenciesInjectionConfiguration.Configure(services);
            services.AddAutoMapper(typeof(Startup));
            ConfigureMapper(services);
        }
        public DependencyInjectionSetupFixture()
        {
            var serviceCollection = new ServiceCollection();

            DependenciesInjectionConfiguration.Configure(serviceCollection, true);

            serviceCollection.AddTransient <IUnitOfWorkEntity>(s => new UnitOfWorkEntity(TestBootstrapper.GetInMemoryDbContextOptions()));
            serviceCollection.AddLogging();
            serviceCollection.AddLocalization(options => options.ResourcesPath = @"Resources");

            ServiceProvider = serviceCollection.BuildServiceProvider();
        }