예제 #1
0
 private void SetupClientWithNullConfigValues()
 {
     this.servicesConfig = new Mock <IServicesConfig>();
     this.client         = new TimeSeriesClient(
         this.httpClient.Object,
         this.servicesConfig.Object,
         this.logger.Object);
 }
예제 #2
0
        /// <summary>Setup Custom rules overriding autowired ones.</summary>
        private static void SetupCustomRules(ContainerBuilder builder)
        {
            // Make sure the configuration is read only once.
            IConfig config = new Config(new ConfigData(new Logger(Uptime.ProcessId, LogLevel.Info)));

            builder.RegisterInstance(config).As <IConfig>().SingleInstance();

            // Service configuration is generated by the entry point, so we
            // prepare the instance here.
            builder.RegisterInstance(config.ServicesConfig).As <IServicesConfig>().SingleInstance();

            // Instantiate only one logger
            // TODO: read log level from configuration
            var logger = new Logger(Uptime.ProcessId, LogLevel.Debug);

            builder.RegisterInstance(logger).As <ILogger>().SingleInstance();

            // Set up storage client for Cosmos DB
            var storageClient = new StorageClient(config.ServicesConfig, logger);

            builder.RegisterInstance(storageClient).As <IStorageClient>().SingleInstance();

            // Set up BLOB storage client
            ICloudStorageWrapper cloudStorageWrapper = new CloudStoragWrapper();
            IBlobStorageHelper   blobStorageHelper   = new BlobStorageHelper(config.BlobStorageConfig, cloudStorageWrapper, logger);

            builder.RegisterInstance(blobStorageHelper).As <IBlobStorageHelper>().SingleInstance();

            // Http
            IHttpClient httpClient = new HttpClient(logger);

            builder.RegisterInstance(httpClient).As <IHttpClient>();

            // Setup Time Series Insights Client
            var timeSeriesClient = new TimeSeriesClient(httpClient, config.ServicesConfig, logger);

            builder.RegisterInstance(timeSeriesClient).As <ITimeSeriesClient>().SingleInstance();

            // Auth and CORS setup
            Auth.Startup.SetupDependencies(builder, config);

            // By default Autofac uses a request lifetime, creating new objects
            // for each request, which is good to reduce the risk of memory
            // leaks, but not so good for the overall performance.
            //builder.RegisterType<CLASS_NAME>().As<INTERFACE_NAME>().SingleInstance();
            builder.RegisterType <UserManagementClient>().As <IUserManagementClient>().SingleInstance();
            builder.RegisterType <DiagnosticsClient>().As <IDiagnosticsClient>().SingleInstance();

            // Event Hub Classes
            IEventProcessorHostWrapper eventProcessorHostWrapper = new EventProcessorHostWrapper();

            builder.RegisterInstance(eventProcessorHostWrapper).As <IEventProcessorHostWrapper>().SingleInstance();
            IEventProcessorFactory eventProcessorFactory = new ActionsEventProcessorFactory(logger, config.ServicesConfig, httpClient);

            builder.RegisterInstance(eventProcessorFactory).As <IEventProcessorFactory>().SingleInstance();
        }
예제 #3
0
 private void SetupClientWithNullConfigValues()
 {
     this.config = new Mock <AppConfig> {
         DefaultValue = DefaultValue.Mock
     };
     this.client = new TimeSeriesClient(
         this.httpClient.Object,
         this.config.Object,
         this.logger.Object);
 }
예제 #4
0
 public TimeSeriesClientTest()
 {
     this.logger         = new Mock <ILogger>();
     this.servicesConfig = new Mock <IServicesConfig>();
     this.httpClient     = new Mock <IHttpClient>();
     this.client         = new TimeSeriesClient(
         this.httpClient.Object,
         this.servicesConfig.Object,
         this.logger.Object);
 }
예제 #5
0
 public TimeSeriesClientTest()
 {
     this.logger = new Mock <ILogger <TimeSeriesClient> >();
     this.config = new Mock <AppConfig> {
         DefaultValue = DefaultValue.Mock
     };
     this.httpClient = new Mock <IHttpClient>();
     this.client     = new TimeSeriesClient(
         this.httpClient.Object,
         this.config.Object,
         this.logger.Object);
 }
예제 #6
0
        private void SetupClientWithConfigValues()
        {
            this.servicesConfig.Setup(f => f.TimeSeriesFqdn).Returns("test123");
            this.servicesConfig.Setup(f => f.TimeSeriesAudience).Returns("test123");
            this.servicesConfig.Setup(f => f.TimeSertiesApiVersion).Returns("2016-12-12-test");
            this.servicesConfig.Setup(f => f.TimeSeriesTimeout).Returns("PT20S");
            this.servicesConfig.Setup(f => f.ActiveDirectoryTenant).Returns("test123");
            this.servicesConfig.Setup(f => f.ActiveDirectoryAppId).Returns("test123");
            this.servicesConfig.Setup(f => f.ActiveDirectoryAppSecret).Returns("test123");
            this.servicesConfig.Setup(f => f.TimeSeriesAuthority).Returns("https://login.testing.net/");

            this.client = new TimeSeriesClient(
                this.httpClient.Object,
                this.servicesConfig.Object,
                this.logger.Object);
        }
예제 #7
0
        private void SetupClientWithConfigValues()
        {
            this.config.Setup(f => f.DeviceTelemetryService.TimeSeries.TsiDataAccessFqdn).Returns("test123");
            this.config.Setup(f => f.DeviceTelemetryService.TimeSeries.Audience).Returns("test123");
            this.config.Setup(f => f.DeviceTelemetryService.TimeSeries.ApiVersion).Returns("2016-12-12-test");
            this.config.Setup(f => f.DeviceTelemetryService.TimeSeries.Timeout).Returns("PT20S");
            this.config.Setup(f => f.Global.AzureActiveDirectory.TenantId).Returns("test123");
            this.config.Setup(f => f.Global.AzureActiveDirectory.AppId).Returns("test123");
            this.config.Setup(f => f.Global.AzureActiveDirectory.AppSecret).Returns("test123");
            this.config.Setup(f => f.DeviceTelemetryService.TimeSeries.Authority).Returns("https://login.testing.net/");
            this.config.Setup(f => f.DeviceTelemetryService.Messages.TelemetryStorageType).Returns("tsi");

            this.client = new TimeSeriesClient(
                this.httpClient.Object,
                this.config.Object,
                this.logger.Object);
        }