public void ConfigureServices(IServiceCollection services)
 {
     services.AddAutoMapper(typeof(MapperProfile));
     services.AddControllers()
     .AddNewtonsoftJson(option =>
                        option.SerializerSettings.ReferenceLoopHandling =
                            Newtonsoft.Json.ReferenceLoopHandling.Ignore
                        );
     services.AddSingleton <IConnectionMultiplexer> (c =>
     {
         var config = ConfigurationOptions.Parse(_configuration.GetConnectionString("Redis"), true);
         return(ConnectionMultiplexer.Connect(config));
     });
     ServicesConfiguration.Configure(services);
     services.AddIdentityService(_configuration);
     SwaggerServiceExtentions.AddSwaggerDocumentation(services);
     services.AddCors(options =>
     {
         options.AddPolicy("CorsPolicy", policy =>
         {
             policy.AllowAnyHeader()
             .AllowAnyMethod()
             .WithOrigins("https://localhost:4200");
         });
     });
 }
Exemple #2
0
        public QuadraFutebolRepositorioTeste()
        {
            var configServices = ServicesConfiguration.Configure();

            _memoryDb = configServices
                        .GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _quadraFutebolRepositorio = new QuadraFutebolRepositorio(_memoryDb);
            _quadraTeste = _memoryDb.Quadras.First();

            _quadrasFake = new Faker <QuadraFutebol>()
                           .RuleFor(sc => sc.Nome, f => f.Company.CompanyName())
                           .RuleFor(sc => sc.Imagem, f => f.Image.PicsumUrl())
                           .RuleFor(sc => sc.PrecoHora, f => f.Random.Decimal(80M, 200M))
                           .RuleFor(sc => sc.Telefone, f => f.Phone.PhoneNumber("(##) ####-####"))
                           .RuleFor(sc => sc.Endereco, f => f.Address.FullAddress())
                           .RuleFor(sc => sc.Cep, f => f.Address.ZipCode("#####-###"))
                           .RuleFor(sc => sc.Latitude, f => f.Address.Latitude())
                           .RuleFor(sc => sc.Longitude, f => f.Address.Longitude())
                           .RuleFor(sc => sc.UsuarioProprietarioId, f => _memoryDb.Usuarios.First().Id);

            _quadraEsperada = new
            {
                Nome      = "Soccer Court 3",
                Imagem    = "soccerCourt3.png",
                PrecoHora = 90M,
                Telefone  = "(11) 3692-1472",
                Endereco  = "Av. teste 321, teste",
                Cep       = "01012-345",
                Latitude  = -23.1096504,
                Longitude = -46.533172,
            };
        }
        public UsuarioRepositorioTeste()
        {
            var configServices = ServicesConfiguration.Configure();

            _memoryDb = configServices
                        .GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _usuarioRepositorio = new UsuarioRepositorio(_memoryDb);
            _usuarioTest        = _memoryDb.Usuarios.First();

            string salt = SenhaHasherHelper.CriarSalt(8);

            _usuarioFake = new Faker <Usuario>()
                           .RuleFor(u => u.Nome, f => f.Person.FirstName)
                           .RuleFor(u => u.Sobrenome, f => f.Person.LastName)
                           .RuleFor(u => u.Email, f => f.Person.Email)
                           .RuleFor(u => u.Telefone, f => f.Person.Phone)
                           .RuleFor(u => u.Username, f => f.UniqueIndex + f.Person.UserName)
                           .RuleFor(u => u.Senha, f => SenhaHasherHelper.GerarHash(f.Internet.Password(), salt))
                           .RuleFor(u => u.Salt, salt)
                           .RuleFor(u => u.TipoUsuario, TipoUsuario.Jogador);

            _usuarioEsperado = new
            {
                Nome        = "Test",
                Sobrenome   = "One",
                Username    = "******",
                Email       = "*****@*****.**",
                Telefone    = "+551155256325",
                TipoUsuario = TipoUsuario.ProprietarioQuadra,
            };
        }
Exemple #4
0
        public ServicoNotificacaoEmailTeste()
        {
            var configServices = ServicesConfiguration.Configure();
            var logger         = configServices.GetRequiredService <ILogger>();
            var smtpSettings   = configServices.GetRequiredService <SmtpConfiguracao>();

            _emailServico = new ServicoNotificacaoEmail(smtpSettings, logger);
        }
Exemple #5
0
        public ServicoNotificacaoSmsTeste()
        {
            var configServices = ServicesConfiguration.Configure();
            var logger         = configServices.GetRequiredService <ILogger>();

            _twilioSettings = configServices.GetRequiredService <TwilioConfiguracao>();

            _smsServico = new ServicoNotificacaoSms(_twilioSettings, logger);
        }
        public PostRepositoryTest()
        {
            var configServices = ServicesConfiguration.Configure();

            _inMemoryDbContext = configServices
                                 .GetRequiredService <DataContext>()
                                 .SeedTestData();
            _postRepository = new PostRepository(_inMemoryDbContext);
        }
        public AutenticacaoHandlerTeste()
        {
            var cfg = ServicesConfiguration.Configure();

            cfg.GetRequiredService <MatchDayAppContext>()
            .SeedFakeData();

            _mediator = cfg.GetRequiredService <IMediator>();
        }
Exemple #8
0
        public AuthorServiceTest()
        {
            var configServices = ServicesConfiguration.Configure();

            _dbContext = configServices
                         .GetRequiredService <DataContext>()
                         .SeedTestData();
            _unit          = configServices.GetService <IUnitOfWork>();
            _authorService = new AuthorService(_unit);
        }
        public PostServiceTest()
        {
            var provider = ServicesConfiguration.Configure();

            _dbContext = provider
                         .GetRequiredService <DataContext>()
                         .SeedTestData();
            _unit        = provider.GetService <IUnitOfWork>();
            _postService = new PostService(_unit);
        }
        public UsuarioHandlerTeste()
        {
            var cfg = ServicesConfiguration.Configure();

            _memoryDb = cfg.GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _mediator  = cfg.GetRequiredService <IMediator>();
            _usuarioId = _memoryDb.Usuarios.Last().Id;
        }
Exemple #11
0
        public PartidaHandlerTeste()
        {
            var cfg = ServicesConfiguration.Configure();

            _memoryDb = cfg.GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _mediator  = cfg.GetRequiredService <IMediator>();
            _partidaId = _memoryDb.Partidas.Last().Id;
        }
        public ConfirmacaoEmailRepositorioTeste()
        {
            var configServices = ServicesConfiguration.Configure();

            _memoryDb = configServices
                        .GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _confirmacaoEmailRepositorio = new ConfirmacaoEmailRepositorio(_memoryDb);
        }
Exemple #13
0
        public PartidaRepositorioTeste()
        {
            var configServices = ServicesConfiguration.Configure();

            _memoryDb = configServices
                        .GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _partidaRepositorio = new PartidaRepositorio(_memoryDb);
            _partidaTeste       = _memoryDb.Partidas.First();
        }
        public UsuarioServicoTeste()
        {
            var cfg = ServicesConfiguration.Configure();

            _memoryDb = cfg.GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();
            _uow = cfg.GetRequiredService <IUnitOfWork>();

            _usuarioServico = new UsuarioServico(_uow,
                                                 cfg.GetRequiredService <IMapper>());
        }
Exemple #15
0
        public TimeHandlerTeste()
        {
            var cfg = ServicesConfiguration.Configure();

            _memoryDb = cfg.GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _mediator = cfg.GetRequiredService <IMediator>();
            _timeId   = _memoryDb.Times.Last().Id;

            _faker = new Faker("pt_BR");
        }
Exemple #16
0
        public CachingServiceTest()
        {
            var provider = ServicesConfiguration.Configure();

            _cache = provider.GetRequiredService <IMemoryCache>();

            _cache.Set("values", new List <string>
            {
                "valor1", "valor2", "valor3"
            });

            _cacheService = new CacheService(_cache);
        }
Exemple #17
0
        public TimeServicoTeste()
        {
            var cfg = ServicesConfiguration.Configure();

            _memoryDb = cfg.GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();
            _uow = cfg.GetRequiredService <IUnitOfWork>();

            _timeServico = new TimeServico(_uow,
                                           cfg.GetRequiredService <IMapper>());

            _timeId = _memoryDb.Times.Last().Id;
        }
Exemple #18
0
        public PartidaServicoTeste()
        {
            var configServices = ServicesConfiguration.Configure();

            _memoryDb = configServices
                        .GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();
            _uow = configServices
                   .GetRequiredService <IUnitOfWork>();

            _partidaServico = new PartidaServico(_uow,
                                                 configServices.GetRequiredService <IMapper>());
        }
        public QuadraFutebolServicoTeste()
        {
            var cfg = ServicesConfiguration.Configure();

            _memoryDb = cfg.GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();
            _uow = cfg.GetRequiredService <IUnitOfWork>();

            _quadraServico = new QuadraFutebolServico(_uow,
                                                      cfg.GetRequiredService <IMapper>());

            _quadraId = _memoryDb.Quadras.Last().Id;
        }
Exemple #20
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     try
     {
         Log.Information($"Calling {nameof(ConfigureServices)}");
         ServicesConfiguration.Configure(services, Configuration, Container);
     }
     catch (System.Exception e)
     {
         Log.Error(e, $"Exception in {nameof(ConfigureServices)}");
         throw e;
     }
 }
Exemple #21
0
        public AutenticacaoServicoTeste()
        {
            var configServices = ServicesConfiguration.Configure();

            configServices.GetRequiredService <MatchDayAppContext>()
            .SeedFakeData();

            _uow = configServices
                   .GetRequiredService <IUnitOfWork>();

            _autenticacaoServico = new AutenticacaoServico(_uow,
                                                           configServices.GetRequiredService <IMapper>(),
                                                           configServices.GetService <JwtConfiguracao>());
        }
Exemple #22
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile(
                path: "appsettings.json",
                optional: false,
                reloadOnChange: true);

            var configuration = builder.Build();

            _container = ServicesConfiguration.Configure(configuration);
            _rpcServer = RpcServerConfiguration.Configure(_container, configuration);

            _rpcServer.Start();

            return(Task.CompletedTask);
        }
Exemple #23
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IConfiguration>(Configuration);

            services.AddOptions();
            services.AddLogging(loggingBuilder =>
            {
                //var loggingConfigSection = Configuration.GetSection(Configuration["Logging"]);
                //loggingBuilder.AddConfiguration(loggingConfigSection);
                //loggingBuilder.AddConsole();
                loggingBuilder.AddProvider(new Logging.CollectorConsoleLoggingProvider());
                loggingBuilder.AddDebug();

                LoggingConfigurator.Configure(loggingBuilder, Configuration);
            });

            ServicesConfiguration.Configure(services, Configuration);
        }
Exemple #24
0
        public AuthorAuthenticationServiceTest(ITestOutputHelper output)
        {
            _faker  = new Faker("pt_BR");
            _output = output;

            var provider = ServicesConfiguration.Configure();

            _dbContext = provider
                         .GetRequiredService <DataContext>()
                         .SeedTestData();
            _unitOfWork = provider.GetRequiredService <IUnitOfWork>();

            _authenticationService = new AuthorAuthenticationService(_unitOfWork,
                                                                     new JwtOptions
            {
                Secret        = "9ce891b219b6fb5b0088e3e05e05baf5",
                TokenLifetime = TimeSpan.FromMinutes(5)
            });
        }
        public TimeRepositorioTeste()
        {
            var configServices = ServicesConfiguration.Configure();

            _memoryDb = configServices
                        .GetRequiredService <MatchDayAppContext>()
                        .SeedFakeData();

            _timeRepositorio = new TimeRepositorio(_memoryDb);
            _timeTeste       = _memoryDb.Times.First();

            _timeFake = new Faker <Time>()
                        .RuleFor(u => u.Nome, f => f.Company.CompanyName())
                        .RuleFor(u => u.Imagem, f => f.Image.PicsumUrl())
                        .RuleFor(u => u.QtdIntegrantes, f => f.Random.Int(6, 16))
                        .RuleFor(u => u.UsuarioProprietarioId, f => _memoryDb.Usuarios.First().Id);

            _timeEsperado = new
            {
                Nome           = "Team 3",
                Imagem         = "team3.png",
                QtdIntegrantes = 11
            };
        }
 private static void ConfigureDependencyInjector(IServiceCollection services)
 {
     ServicesConfiguration.Configure(services);
 }
Exemple #27
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            var path = Directory.GetCurrentDirectory();

            loggerFactory.AddFile($"{path}\\Logs\\Log.txt");

            Console.WriteLine("Environment Startup: " + env.EnvironmentName);
            if (env.IsDevelopment())
            {
                Console.WriteLine("ExceptionHandler Development: " + env.EnvironmentName);
                app.UseExceptionHandler(errorApp =>
                {
                    errorApp.Run(async context =>
                    {
                        loggerFactory.CreateLogger("Error").LogError(context.Features.Get <IExceptionHandlerFeature>().Error.Message);
                        context.Response.StatusCode  = 500;
                        context.Response.ContentType = "text/html";

                        await context.Response.WriteAsync("<html lang=\"en\"><body>\r\n");
                        await context.Response.WriteAsync("ERROR!<br><br>\r\n");

                        var exceptionHandlerPathFeature =
                            context.Features.Get <IExceptionHandlerPathFeature>();

                        if (exceptionHandlerPathFeature?.Error is FileNotFoundException)
                        {
                            await context.Response.WriteAsync(
                                "File error thrown!<br><br>\r\n");
                        }

                        await context.Response.WriteAsync(
                            "<a href=\"/\">Home</a><br>\r\n");
                        await context.Response.WriteAsync("</body></html>\r\n");
                        await context.Response.WriteAsync(new string(' ', 512));
                    });
                });
                //app.UseDeveloperExceptionPage();
                var servicesConfig = new ServicesConfiguration();
                servicesConfig.Configure(app, env);
            }
            else
            {
                Console.WriteLine("ExceptionHandler Release: " + env.EnvironmentName);
                app.UseExceptionHandler(errorApp =>
                {
                    errorApp.Run(async context =>
                    {
                        loggerFactory.CreateLogger("Error").LogError(context.Features.Get <IExceptionHandlerFeature>().Error.Message);
                    });
                });
                // app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                // app.UseHsts();
            }

            var cookiePolicyOptions = new CookiePolicyOptions
            {
                MinimumSameSitePolicy = SameSiteMode.Unspecified,
            };

            app.UseCookiePolicy(cookiePolicyOptions);
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseCors(x => x.WithOrigins("http://localhost:3000").AllowAnyMethod().AllowCredentials().AllowAnyHeader());
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapAreaControllerRoute(
                    name: "areaIdentity",
                    areaName: "Identity",
                    pattern: "Identity/{controller=Account}/{action=Index}/{id?}");
                endpoints.MapAreaControllerRoute(
                    name: "areaAdmin",
                    areaName: "Admin",
                    pattern: "Admin/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapAreaControllerRoute(
                    name: "default",
                    areaName: "Client",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapAreaControllerRoute(
                    name: "blogs",
                    areaName: "Client",
                    pattern: "blogs/{*slug}",
                    defaults: new { controller = "Blogs", action = "Index" }
                    );
                endpoints.MapControllerRoute(
                    name: "common",
                    pattern: "request/{controller}/{action}/{id?}",
                    defaults: new { controller = "FileManager", action = "GetBlogFiles" }
                    );

                endpoints.MapRazorPages();
                endpoints.MapHub <AdminNotificationHub>("/admin/notification");
                endpoints.MapHub <OnlineHub>("/client/online");
                endpoints.MapHub <ChatHub>("/client/chat");
            });
        }
Exemple #28
0
 private static void ConfigureDependencyInjector(IServiceCollection services)
 {
     QueriesConfiguration.Configure(services);
     ConfigureEvents(services);
     ServicesConfiguration.Configure(services);
 }
Exemple #29
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ServicesConfiguration.Configure(services, Configuration);
 }
Exemple #30
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.AddAutoMapper(typeof(MappingProfile));  // auto mapper configureren! met deze lijn
     ServicesConfiguration.Configure(services, Configuration);
 }