Beispiel #1
0
 public TeamServiceTests()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _teamService = _mocker.CreateInstance <TeamService>();
 }
Beispiel #2
0
        public UserServiceTests()
        {
            services = new ServicesBuilder();
            _mocker  = new AutoMocker();
            services.Build(_mocker);


            _roleManager = services.GetRoleManager();
            _mocker.Use(_roleManager);

            _userManager = services.GetUserManager();
            _mocker.Use(_userManager);

            _roleManager.CreateAsync(new LiteDbRole {
                Name = "Admin"
            }).GetAwaiter().GetResult();
            _roleManager.CreateAsync(new LiteDbRole {
                Name = "Mod"
            }).GetAwaiter().GetResult();
            _roleManager.CreateAsync(new LiteDbRole {
                Name = "Captain"
            }).GetAwaiter().GetResult();
            _roleManager.CreateAsync(new LiteDbRole {
                Name = "User"
            }).GetAwaiter().GetResult();

            _userService = _mocker.CreateInstance <UserService>();
        }
 public MapServiceTests()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _mapsService = _mocker.CreateInstance <MapsService>();
 }
 public SteamIdentityServiceTest()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _steamIdentityService = _mocker.CreateInstance <SteamIdentityService>();
 }
 public SshServerServiceTests()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _sshServerSerivce    = _mocker.CreateInstance <SshServerSerivce>();
     _pavlovServerService = _mocker.CreateInstance <PavlovServerService>();
 }
        public IConnectionBuilder UseServices <TBuilder>(Func <TBuilder, IServicesBuilder <IConnection> > config)
            where TBuilder : IServicesBuilder <IConnection>
        {
            var builder = Activator.CreateInstance <TBuilder>();

            _services = config.Invoke(builder);
            return(this);
        }
        /// <summary>Add the core services</summary>
        public static IServicesBuilder <TOptions> AddCoreServices <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            // Core services
            builder.Services.AddHttpClient();
            builder.Services.AddRequestProvider();

            return(builder);
        }
        /// <summary>Add the required health checks</summary>
        public static IServicesBuilder <TOptions> AddHealthChecks <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            builder.Services.AddHealthChecks()
            .AddDiskStorageHealthCheck(setup => setup.AddDrive(System.IO.Path.GetPathRoot(Environment.CurrentDirectory), 1024), name: "Disk storage")
            .AddPrivateMemoryHealthCheck(1024 * 1024 * 1024, name: "Private memory");

            return(builder);
        }
 public TeamSelectedSteamIdentityServiceTest()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _userManager                      = services.GetUserManager();
     _steamIdentityService             = _mocker.CreateInstance <SteamIdentityService>();
     _teamSelectedSteamIdentityService = _mocker.CreateInstance <TeamSelectedSteamIdentityService>();
     _teamService                      = _mocker.CreateInstance <TeamService>();
 }
        /// <summary>Add the IIS services</summary>
        public static IServicesBuilder <TOptions> AddCorsServices <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            builder.Services.AddCors(options => options.AddPolicy("AllowAll", p => p
                                                                  .AllowAnyOrigin()
                                                                  .AllowAnyHeader()
                                                                  .AllowAnyMethod()));

            return(builder);
        }
        /// <summary>Add the IIS services</summary>
        public static IServicesBuilder <TOptions> AddIISServices <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            builder.Services.Configure <IISOptions>(options =>
            {
                options.AutomaticAuthentication = false;
            });

            return(builder);
        }
Beispiel #12
0
 public PublicViewListsServiceTest()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _pavlovServerService       = _mocker.CreateInstance <PavlovServerService>();
     _sshServerSerivce          = _mocker.CreateInstance <SshServerSerivce>();
     _pavlovServerInfoService   = _mocker.CreateInstance <PavlovServerInfoService>();
     _pavlovServerPlayerService = _mocker.CreateInstance <PavlovServerPlayerService>();
     _publicViewListsService    = _mocker.CreateInstance <PublicViewListsService>();
 }
Beispiel #13
0
 public ServerSelectedWhitelistServiceTests()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _serverSelectedWhitelistService = _mocker.CreateInstance <ServerSelectedWhitelistService>();
     _steamIdentityService           = _mocker.CreateInstance <SteamIdentityService>();
     _pavlovServerService            = _mocker.CreateInstance <PavlovServerService>();
     _sshServerSerivce = _mocker.CreateInstance <SshServerSerivce>();
     _userManager      = services.GetUserManager();
 }
        public static IServicesBuilder <TOptions> AddCookiePolicy <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            // Cookies policy (user content for non-essential cookies is needed for a given request)
            builder.Services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            return(builder);
        }
 public MatchServiceTest()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _pavlovServerService  = _mocker.CreateInstance <PavlovServerService>();
     _sshServerSerivce     = _mocker.CreateInstance <SshServerSerivce>();
     _teamService          = _mocker.CreateInstance <TeamService>();
     _matchService         = _mocker.CreateInstance <MatchService>();
     _steamIdentityService = _mocker.CreateInstance <SteamIdentityService>();
     _matchSelectedSteamIdentitiesService     = _mocker.CreateInstance <MatchSelectedSteamIdentitiesService>();
     _matchSelectedTeamSteamIdentitiesService =
         _mocker.CreateInstance <MatchSelectedTeamSteamIdentitiesService>();
     _userManager = services.GetUserManager();
 }
        public PavlovServerServiceTests()
        {
            services = new ServicesBuilder();
            _mocker  = new AutoMocker();
            services.Build(_mocker);
            _userManager = services.GetUserManager();

            // Mock ValidatePavlovServer function
            var tmpService = _mocker
                             .Setup <PavlovServerService, Task <PavlovServer> >(x =>
                                                                                x.ValidatePavlovServer(It.IsAny <PavlovServer>(), It.IsAny <bool>()))
                             .ReturnsAsync((PavlovServer server, bool root) => server);

            _mocker.Use(tmpService);
            _pavlovServerService = _mocker.GetMock <PavlovServerService>().Object;


            _sshServerSerivce          = _mocker.CreateInstance <SshServerSerivce>();
            _serverSelectedModsService = _mocker.CreateInstance <ServerSelectedModsService>();
            _steamIdentityService      = _mocker.CreateInstance <SteamIdentityService>();
        }
Beispiel #17
0
        public static IServicesBuilder AddEvenets(this IServicesBuilder serviceBuilder, Action <IEventOptionsBuilder> configurator) =>
        serviceBuilder.AddServices(services =>
        {
            var eventBuilder = new EventOptionsBuilder();
            configurator.Invoke(eventBuilder);

            var eventOptions = eventBuilder.Build();
            foreach (var o in eventOptions)
            {
                if (o.ConsumerType != null && !o.ConsumerType.IsInterface)
                {
                    services.AddScoped(o.ConsumerType);
                }

                if (o.ConverterType == null)
                {
                    throw new EventConfigurationException(o.EventName, o.EventType,
                                                          $"Converter for '{o.EventName}' event not configured, this configuration is necessary.");
                }

                if (!o.ConverterType.IsInterface)
                {
                    services.AddScoped(o.ConverterType);
                }
            }

            services.AddSingleton(serviceProvider =>
            {
                StaticCache.EventProvider = new EventProvider(
                    serviceProvider,
                    serviceProvider.GetRequiredService <ITopicPattenBuilder>(),
                    eventOptions,
                    serviceProvider.GetRequiredService <IEventBusLogger <EventProvider> >());
                return(StaticCache.EventProvider);
            });
        }, ServiceType.Event);
Beispiel #18
0
 public static IServicesBuilder AddLogger(this IServicesBuilder builder, Action <ILoggerOptionsBuilder> loggerConfigurator) =>
 builder.AddServices(services =>
 {
     var loggerBuilder = new LoggerOptionsBuilder(services);
     loggerConfigurator.Invoke(loggerBuilder);
 }, ServiceType.Logger);
 public static IServicesBuilder <T> AddEntanglementHost <T>(this IServicesBuilder <T> services,
                                                            Action <IEntanglementHostService> config = null) where T : class, ICommon
 {
     services.Add <IEntanglementHostService, EntanglementHostService>(config);
     return(services);
 }
Beispiel #20
0
        public override void ConfigureServices(IServicesBuilder builder, RunConfiguration configuration)
        {
            builder.RegisterPerFeatureService <Browser>();

            builder.RegisterPerResolveService <InteractionMethods>();
        }
 public IConnectionBuilder UseServices(IServicesBuilder <IConnection> services)
 {
     _services = services;
     return(this);
 }
        /// <summary>Add the required platform services</summary>
        public static IServicesBuilder <TOptions> AddRequiredPlatformServices <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            // Required platform services
            builder.Services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            builder.Services.AddOptions();
            builder.Services.AddSingleton(resolver => resolver.GetRequiredService <IOptions <TOptions> >().Value);

            return(builder);
        }
Beispiel #23
0
 public static IServicesBuilder AddSerilog(this IServicesBuilder builder, Action <LoggerConfiguration> configure)
 => builder.AddLogger(p => p.UseSerilog(configure));
 public static IServicesBuilder AddMicrosoftExtensionsLgger(this IServicesBuilder builder, Action <ILoggingBuilder> configure)
 => builder.AddLogger(p => p.UseMicrosoftExtension(configure));
 public static IServicesBuilder AddMicrosoftExtensionsLgger(this IServicesBuilder builder)
 => builder.AddLogger(p => p.UseMicrosoftExtension());
Beispiel #26
0
        public static IServicesBuilder <TOptions> AddSwaggerServices <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            var applicationName = builder.Options.ApplicationName;
            var documentation   = builder.Options.Documentation ?? new DocumentationOptions();
            var version         = documentation.Version ?? "v1";
            var contact         = new Contact
            {
                Email = builder.Options.Contact?.Technical?.Email
            };

            builder.Services.AddSwaggerGen(c =>
            {
                // Main information
                c.SwaggerDoc(version, new Info
                {
                    Title       = $"{applicationName} API",
                    Version     = version,
                    Description = $"All public API proposed by {applicationName} application",
                    Contact     = contact
                });

                // Security
                if (documentation.EnableSecurity)
                {
                    c.AddSecurityDefinition("Bearer", new ApiKeyScheme
                    {
                        Description = "JWT Authorization header using the Bearer scheme. Example: \"Bearer {token}\"",
                        Name        = "Authorization",
                        In          = "header",
                        Type        = "apiKey"
                    });

                    c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> >()
                    {
                        { "Bearer", new string[] { } }
                    });
                }

                // XML comments file
                if (!string.IsNullOrEmpty(documentation.XmlCommentsFilePath))
                {
                    c.IncludeXmlComments(documentation.XmlCommentsFilePath);
                }

                // Formatting
                if (documentation.DescribeAllEnumsAsStrings)
                {
                    c.DescribeAllEnumsAsStrings();
                }
                if (documentation.DescribeAllParametersInCamelCase)
                {
                    c.DescribeAllParametersInCamelCase();
                }
                if (documentation.DescribeStringEnumsInCamelCase)
                {
                    c.DescribeStringEnumsInCamelCase();
                }
            });

            return(builder);
        }
Beispiel #27
0
        /// <summary>Add the core services</summary>
        public static IServicesBuilder <TOptions> AddDocumentationServices <TOptions>(this IServicesBuilder <TOptions> builder)
            where TOptions : ServicesOptions, new()
        {
            // Documentation microservices
            builder.AddSwaggerServices();

            return(builder);
        }
 public UserStoreTests()
 {
     services = new ServicesBuilder();
     services.Build();
 }
Beispiel #29
0
 public static IServicesBuilder AddSerilog(this IServicesBuilder builder, ILogger logger)
 => builder.AddLogger(p => p.UseSerilog(logger));
Beispiel #30
0
 private IServicesBuilder <IConnection> method_14(IServicesBuilder <IConnection> iservicesBuilder_0)
 {
     return(iservicesBuilder_0.AddInstance <IEntanglementHostService, EntanglementHostService>(this.entanglementHostService_0, null).AddEntanglementClient(null));
 }