Пример #1
0
        public EntitlementProxyTests()
        {
            var name = GetType().FullName + ".log";

            _loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure(name));
            _dataCache     = new InMemoryDataCache(_loggerFactory, new MemoryCache(new MemoryCacheOptions()));
        }
Пример #2
0
        public UnitTestsDIFixture()
        {
            AutoMapperUtility.AutomapperConfiguration.AssertConfigurationIsValid();

            var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Project.UnitTests.log"));

            ServiceCollection = new ServiceCollection();

            ServiceCollection.AddLogging();
            ServiceCollection.AddSingleton(loggerFactory);
            ServiceCollection
            .AddTransient <IProjectRepository, ProjectRepository>()
            .AddSingleton <IConfigurationStore, GenericConfiguration>()
            .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()
            .AddTransient <IProductivity3dV1ProxyCoord, Productivity3dV1ProxyCoord>()
            .AddTransient <IProductivity3dV2ProxyNotification, Productivity3dV2ProxyNotification>()
            .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>()
            .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>();

            ServiceProvider         = ServiceCollection.BuildServiceProvider();
            ServiceExceptionHandler = ServiceProvider.GetRequiredService <IServiceExceptionHandler>();

            _log           = ServiceProvider.GetRequiredService <ILoggerFactory>().CreateLogger <T>();
            _loggerFactory = ServiceProvider.GetRequiredService <ILoggerFactory>();
            _customHeaders = new HeaderDictionary();
            _configStore   = ServiceProvider.GetRequiredService <IConfigurationStore>();

            _userUid     = Guid.NewGuid();
            _customerUid = Guid.NewGuid();
            _customerTrn = TRNHelper.MakeTRN(_customerUid, TRNHelper.TRN_ACCOUNT);
            _projectUid  = Guid.NewGuid();
            _projectTrn  = TRNHelper.MakeTRN(_projectUid);
            _customHeaders.Add("X-VisionLink-CustomerUID", new StringValues(_customerUid.ToString()));
        }
Пример #3
0
        public virtual void InitTest()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection
            .AddLogging()
            .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.TagFileAuth.WepApiTests.log")))
            .AddSingleton <IConfigurationStore, GenericConfiguration>();

            ServiceProvider = serviceCollection.BuildServiceProvider();
            ConfigStore     = ServiceProvider.GetRequiredService <IConfigurationStore>();

            projectProxy            = new Mock <IProjectInternalProxy>();
            deviceProxy             = new Mock <IDeviceInternalProxy>();
            tRexCompactionDataProxy = new Mock <ITRexCompactionDataProxy>();
            requestCustomHeaders    = new HeaderDictionary();
            loggerFactory           = ServiceProvider.GetRequiredService <ILoggerFactory>();
            authorization           = new Mock <ITPaaSApplicationAuthentication>();

            authorization.Setup(x => x.CustomHeaders()).Returns(new HeaderDictionary
            {
                { HeaderConstants.CONTENT_TYPE, ContentTypeConstants.ApplicationJson },
                { HeaderConstants.AUTHORIZATION, "Bearer TOKEN" }
            });
        }
Пример #4
0
        public GetDeviceBySerialExecutorTests()
        {
            var loggerFactory     = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Project.WebApi.log"));
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging();
            serviceCollection.AddSingleton(loggerFactory);
            serviceCollection
            .AddSingleton <IConfigurationStore, GenericConfiguration>()
            .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()
            .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>();

            ServiceProvider          = serviceCollection.BuildServiceProvider();
            _serviceExceptionHandler = ServiceProvider.GetRequiredService <IServiceExceptionHandler>();
            _configStore             = ServiceProvider.GetRequiredService <IConfigurationStore>();
            _logger = ServiceProvider.GetRequiredService <ILoggerFactory>();
            _serviceExceptionHandler = ServiceProvider.GetRequiredService <IServiceExceptionHandler>();
            _customHeaders           = new HeaderDictionary();

            _customerUid     = Guid.NewGuid().ToString();
            _deviceUid       = Guid.NewGuid().ToString();
            _deviceName      = "the Device Name";
            _serialNumber    = "67567576SN";
            _relationStatus  = RelationStatusEnum.Active;
            _tccDeviceStatus = TCCDeviceStatusEnum.Registered;
        }
Пример #5
0
 public void InitTest()
 {
     serviceProvider = new ServiceCollection()
                       .AddLogging()
                       .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure()))
                       .BuildServiceProvider();
 }
Пример #6
0
 public static IHostBuilder CreateHostBuilder(string[] args) =>
 Host.CreateDefaultBuilder(args)
 .UseWindowsService()
 .ConfigureAppConfiguration((context, config) =>
 {
     // Configure the app here.
     config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
 })
 .ConfigureServices((hostContext, services) => { services.AddHostedService <MegalodonService>()
                                                 .AddHostedService <TagFileDispatchSvc>()
                                                 .AddSingleton <IConfigurationStore, GenericConfiguration>()
                                                 .AddSingleton <ISocketManager, SocketManager>()
                                                 .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>()
                                                 .AddSingleton <ITPaaSApplicationAuthentication, TPaaSApplicationAuthentication>()
                                                 .AddSingleton <ITPaasProxy, TPaasProxy>()
                                                 .AddHttpClient()
                                                 .AddSingleton <IWebRequest, GracefulWebRequest>()
                                                 .AddSingleton <IDataCache, InMemoryDataCache>()
                                                 .AddSingleton <IMemoryCache, MemoryCache>()
                                                 .AddSingleton <ITRexTagFileProxy, TRexTagFileV2Proxy>()
                                                 .AddServiceDiscovery(); })
 .ConfigureLogging((hostContext, loggingBuilder) =>
 {
     var generalConfig = new ConfigurationBuilder()
                         .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                         .Build();
     loggingBuilder.ClearProviders();
     loggingBuilder.AddProvider(
         p => new SerilogLoggerProvider(
             SerilogExtensions.Configure(config: generalConfig, httpContextAccessor: p.GetService <IHttpContextAccessor>())));
 });
Пример #7
0
        public static IWebHostBuilder BuildKestrelWebHost(this IWebHostBuilder builder)
        {
            var configurationRoot = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
                                    .AddJsonFile("kestrelsettings.json", optional: true, reloadOnChange: false)
                                    .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
                                    .Build();

            builder
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseConfiguration(configurationRoot)
            .ConfigureLogging((hostContext, loggingBuilder) =>
            {
                loggingBuilder.AddProvider(
                    p => new SerilogLoggerProvider(
                        SerilogExtensions.Configure(config: configurationRoot, httpContextAccessor: p.GetService <IHttpContextAccessor>())));
            })
            .ConfigureServices(services =>
            {
                // Setup the ConfigurationRoot so it's available in BaseStartup.
                services.AddSingleton <IConfigurationRoot>(configurationRoot);
            });

            ThreadPool.SetMaxThreads(1024, 2048);
            ThreadPool.SetMinThreads(1024, 2048);

            //Check how many requests we can execute
            ServicePointManager.DefaultConnectionLimit = 128;
            return(builder);
        }
Пример #8
0
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .AddCommandLine(args)
                         .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
                         .AddJsonFile("kestrelsettings.json", optional: true, reloadOnChange: false)
                         .Build();

            new WebHostBuilder().BuildHostWithReflectionException(builder =>
            {
                return(builder.UseConfiguration(config)
                       .UseKestrel()
                       .UseLibuv(opts =>
                {
                    opts.ThreadCount = 32;
                })
                       .UseStartup <Startup>()
                       .ConfigureLogging((hostContext, loggingBuilder) =>
                {
                    loggingBuilder.AddProvider(
                        p => new SerilogLoggerProvider(
                            SerilogExtensions.Configure("CCSS.Productivity3D.Preferences.WebAPI.log", config, p.GetService <IHttpContextAccessor>())));
                })
                       .Build());
            }).Run();
        }
Пример #9
0
        public ExecutorTestFixture()
        {
            var loggerFactory     = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("IntegrationTests.ExecutorTests.log", null));
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging()
            .AddSingleton(loggerFactory)
            .AddHttpClient()
            .AddSingleton <IConfigurationStore, GenericConfiguration>()
            .AddTransient <IRepository <IProjectEvent>, ProjectRepository>()
            .AddTransient <ICwsProjectClient, CwsProjectClient>()
            .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()

            // for serviceDiscovery
            .AddServiceDiscovery()
            .AddTransient <IWebRequest, GracefulWebRequest>()
            .AddMemoryCache()
            .AddSingleton <IDataCache, InMemoryDataCache>()

            .AddTransient <IProductivity3dV1ProxyCoord, Productivity3dV1ProxyCoord>()
            .AddTransient <IProductivity3dV2ProxyNotification, Productivity3dV2ProxyNotification>()
            .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>()
            .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>();


            _serviceProvider                = serviceCollection.BuildServiceProvider();
            ConfigStore                     = _serviceProvider.GetRequiredService <IConfigurationStore>();
            Logger                          = _serviceProvider.GetRequiredService <ILoggerFactory>();
            ServiceExceptionHandler         = _serviceProvider.GetRequiredService <IServiceExceptionHandler>();
            ProjectRepo                     = _serviceProvider.GetRequiredService <IRepository <IProjectEvent> >() as ProjectRepository;
            CwsProjectClient                = _serviceProvider.GetRequiredService <ICwsProjectClient>();
            Productivity3dV2ProxyCompaction = _serviceProvider.GetRequiredService <IProductivity3dV2ProxyCompaction>();
        }
Пример #10
0
        public LineworkExecutorTests()
        {
            serviceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                              .BuildServiceProvider();

            logger         = serviceProvider.GetRequiredService <ILoggerFactory>();
            _customHeaders = new HeaderDictionary();

            var configStoreMock = new Mock <IConfigurationStore>();

            configStoreMock.Setup(x => x.GetValueBool("TREX_IS_AVAILABLE")).Returns(true);
            configStoreMock.Setup(x => x.GetValueBool("ENABLE_TREX_GATEWAY_LINEWORKFILE")).Returns(true);

            configStore = configStoreMock.Object;

            var mockTrexCompactionDataProxy = new Mock <ITRexCompactionDataProxy>();

            mockTrexCompactionDataProxy.Setup(x =>
                                              x.SendDataPostRequest <DXFBoundaryResult, DXFBoundariesRequest>(It.IsAny <DXFBoundariesRequest>(), It.IsAny <string>(), It.IsAny <IHeaderDictionary>(), It.IsAny <bool>()))
            .Returns((DXFBoundariesRequest req, string route, IHeaderDictionary customHeaders, bool mutableGateway) =>
            {
                return(Task.FromResult(new DXFBoundaryResult(ContractExecutionStatesEnum.ExecutedSuccessfully, "Success", TestResultBoundary())));
            });
            trexCompactionDataProxy = mockTrexCompactionDataProxy.Object;
        }
Пример #11
0
 public TestBase()
 {
     ServiceProvider = new ServiceCollection()
                       .AddLogging()
                       .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("AssetMgmt.UnitTests.log")))
                       .BuildServiceProvider();
 }
Пример #12
0
        private static void ConfigureServices(IServiceCollection services)
        {
            var config = new ConfigurationBuilder().AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
                         .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ENVIRONMENT_NAME")}.json", optional: true, reloadOnChange: false)
                         .AddJsonFile($"./DeploymentData/projects.{Environment.GetEnvironmentVariable("ENVIRONMENT_NAME")}.json", optional: false, reloadOnChange: false)
                         .Build();

            var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("TCCToDataOcean.log"));

            services.AddLogging()
            .AddMemoryCache()
            .AddSingleton(loggerFactory);

            services.AddSingleton <ITPaaSApplicationAuthentication, TPaaSApplicationAuthentication>();
            services.AddSingleton <IConfigurationStore, GenericConfiguration>(_ => new GenericConfiguration(loggerFactory, config));
            services.AddSingleton <IConfiguration>(config);
            services.AddScoped <IProjectRepository, ProjectRepository>();
            services.AddScoped <IErrorCodesProvider, MigrationErrorCodesProvider>();
            services.AddScoped <IServiceExceptionHandler, ServiceExceptionHandler>();
            services.AddSingleton <IEnvironmentHelper, EnvironmentHelper>();
            services.AddTransient <IFileRepository, FileRepository>();
            services.AddTransient <IWebApiUtils, WebApiUtils>();
            services.AddSingleton <IRestClient, RestClient>();
            services.AddTransient <IImportFile, ImportFile>();
            services.AddTransient <IMigrator, Migrator>();
            services.AddTransient <ITPaasProxy, TPaasProxy>();
            services.AddSingleton <ILiteDbAgent, LiteDbAgent>();
            services.AddSingleton <ICSIBAgent, CSIBAgent>();
            services.AddSingleton <IDataOceanAgent, DataOceanAgent>();
            services.AddSingleton <ICalibrationFileAgent, CalibrationFileAgent>();
        }
Пример #13
0
        public void RequireCustomer_No_TagFilesAndHasNoCustomer()
        {
            var mockHttpContext = new Mock <HttpContext>();

            Task MockRequestDelegate(HttpContext context) => Task.FromResult(mockHttpContext.Object);

            var mockCwsAccountClient      = new Mock <ICwsAccountClient>();
            var mockConfigStoreProxy      = new Mock <IConfigurationStore>();
            var loggerFactoryProxy        = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log"));
            var mockServiceExceptionProxy = new Mock <IServiceExceptionHandler>();
            var mockProjectProxy          = new Mock <IProjectProxy>();
            var mockEntitlements          = new Mock <IEntitlementProxy>();

            var raptorAuthentication = new RaptorAuthentication(MockRequestDelegate,
                                                                mockCwsAccountClient.Object, mockConfigStoreProxy.Object, loggerFactoryProxy, mockEntitlements.Object, mockServiceExceptionProxy.Object, mockProjectProxy.Object);

            var request = new DefaultHttpContext().Request;

            request.Path = "/api/v2/tagfiles";
            request.Headers.Add(new KeyValuePair <string, StringValues>("X-VisionLink-SomethingElse", "SomethingElse"));
            request.Method = "POST";
            var isCustomerUidRequired = raptorAuthentication.RequireCustomerUid(request.HttpContext);

            isCustomerUidRequired.Should().BeFalse();
        }
Пример #14
0
 public TransferProxyFactoryTests()
 {
     serviceProvider = new ServiceCollection()
                       .AddLogging()
                       .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.AWS.TransferProxy.UnitTests.log")))
                       .AddSingleton <IConfigurationStore, GenericConfiguration>()
                       .BuildServiceProvider();
 }
Пример #15
0
        public void Should_not_throw_if_appsettingsjson_not_found()
        {
            var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Serilog.Extensions.UnitTests.log"));

            new ServiceCollection().AddLogging()
            .AddSingleton(loggerFactory)
            .BuildServiceProvider();
        }
Пример #16
0
        public void TestInitialize()
        {
            loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Scheduler.Jobs.UnitTests"));
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging()
            .AddSingleton(loggerFactory);
        }
Пример #17
0
 public void InitTest()
 {
     ServiceProvider = new ServiceCollection()
                       .AddLogging()
                       .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                       .AddTransient <IOptions <MemoryCacheOptions>, MemoryCacheOptions>()
                       .BuildServiceProvider();
 }
Пример #18
0
        public ServiceDiscoveryExtensionMethods()
        {
            var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Common.ServiceDiscovery.UnitTests.log"));

            serviceCollection = new ServiceCollection()
                                .AddLogging()
                                .AddSingleton(loggerFactory)
                                .AddSingleton <IConfigurationStore>(mockConfiguration);
        }
Пример #19
0
        public BoundingBoxServiceTests()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Tile.Service.UnitTests.log")))
                                  .BuildServiceProvider();

            loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>();
        }
Пример #20
0
        public KubernetesServiceResolverTests()
        {
            var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Common.ServiceDiscovery.UnitTests.log"));

            serviceCollection = new ServiceCollection()
                                .AddLogging()
                                .AddSingleton(loggerFactory)
                                .AddSingleton <IConfigurationStore>(mockConfiguration)
                                .AddSingleton <IServiceResolver, KubernetesServiceResolver>();
        }
Пример #21
0
        public static void ClassInit(TestContext context)
        {
            serviceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                              .BuildServiceProvider();

            logger         = serviceProvider.GetRequiredService <ILoggerFactory>();
            _customHeaders = new HeaderDictionary();
        }
Пример #22
0
        public AlignmentGeometryExecutorTests()
        {
            serviceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                              .BuildServiceProvider();

            logger         = serviceProvider.GetRequiredService <ILoggerFactory>();
            _customHeaders = new HeaderDictionary();
        }
Пример #23
0
        public PegasusClientTestsBase()
        {
            serviceCollection = new ServiceCollection()
                                .AddLogging()
                                .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Pegasus.Client.UnitTests.log")))
                                .AddSingleton <Common.Abstractions.Configuration.IConfigurationStore, GenericConfiguration>()
                                .AddTransient <IPegasusClient, PegasusClient>();

            serviceProvider = serviceCollection.BuildServiceProvider();
        }
Пример #24
0
        public ConfigurationStoreTests()
        {
            var loggerFactory     = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.ConfigurationStore.UnitTests.log"));
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddLogging();
            serviceCollection.AddSingleton(loggerFactory);
            serviceCollection.AddSingleton <IConfigurationStore, GenericConfiguration>();
            ServiceProvider = serviceCollection.BuildServiceProvider();
        }
Пример #25
0
        public static void ClassInit(TestContext context)
        {
            _serviceProvider = new ServiceCollection()
                               .AddLogging()
                               .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                               .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()
                               .BuildServiceProvider();

            _logger = _serviceProvider.GetRequiredService <ILoggerFactory>();
        }
Пример #26
0
 public MemoryCacheTestsFixture()
 {
     serviceCollection = new ServiceCollection()
                         .AddLogging()
                         .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.MasterData.Proxies.UnitTests.log")))
                         .AddSingleton <IConfigurationStore, GenericConfiguration>()
                         .AddTransient <IMemoryCache, MemoryCache>()
                         .AddHttpClient();
     //.BuildServiceProvider();
 }
Пример #27
0
 public static IHostBuilder CreateHostBuilder(string[] args) =>
 Host.CreateDefaultBuilder(args)
 .ConfigureWebHostDefaults(webBuilder =>
 {
     webBuilder.ConfigureLogging((hostContext, loggingBuilder) =>
     {
         loggingBuilder.AddProvider(
             p => new SerilogLoggerProvider(SerilogExtensions.Configure()));
     })
     .UseStartup <Startup>();
 });
Пример #28
0
        /// <summary>
        /// Adds logging to the DI collection
        /// </summary>
        public DIBuilder AddLogging()
        {
            // Create the LoggerFactory instance for the service collection
            var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure());

            // Insert this immediately into the TRex.Logging namespace to get logging available as early as possible
            Logging.Logger.Inject(loggerFactory);

            // Add the logging related services to the collection
            return(Add(x => { x.AddSingleton(loggerFactory); }));
        }
Пример #29
0
        public static void ClassInit(TestContext context)
        {
            serviceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                              .AddSingleton <IConfigurationStore, GenericConfiguration>()
                              .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>()
                              .AddTransient <IErrorCodesProvider, RaptorResult>().BuildServiceProvider();

            logger = serviceProvider.GetRequiredService <ILoggerFactory>();
        }
Пример #30
0
        public static void ClassInit(TestContext context)
        {
            serviceProvider = new ServiceCollection()
                              .AddLogging()
                              .AddSingleton(new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Productivity3D.WebApi.Tests.log")))
                              .BuildServiceProvider();

            logger = serviceProvider.GetRequiredService <ILoggerFactory>();

            uploadUtility = new RaptorFileUploadUtility(logger);
        }