예제 #1
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfiguration configuration) :
     base(configuration)
 {
     _openApi = new OpenApiConfig(configuration);
     _host    = new WebHostConfig(configuration);
     _hub     = new IoTHubConfig(configuration);
     _cors    = new CorsConfig(configuration);
     _fh      = new ForwardedHeadersConfig(configuration);
     _cr      = new ContainerRegistryConfig(configuration);
 }
예제 #2
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfiguration configuration) :
     base(configuration)
 {
     _openApi = new OpenApiConfig(configuration);
     _host    = new HostConfig(configuration);
     _auth    = new AuthConfig(configuration);
     _cors    = new CorsConfig(configuration);
     _hub     = new IoTHubConfig(configuration);
     _cr      = new ContainerRegistryConfig(configuration);
 }
예제 #3
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfiguration configuration) :
     base(configuration)
 {
     _openApi = new OpenApiConfig(configuration);
     _host    = new WebHostConfig(configuration);
     _hub     = new IoTHubConfig(configuration);
     _cors    = new CorsConfig(configuration);
     _sb      = new ServiceBusConfig(configuration);
     _cosmos  = new CosmosDbConfig(configuration);
     _fh      = new ForwardedHeadersConfig(configuration);
     _cr      = new ContainerRegistryConfig(configuration);
     _lwc     = new LogWorkspaceConfig(configuration);
 }
예제 #4
0
        /// <summary>
        /// Setup mock
        /// </summary>
        /// <param name="ioTHubConfigurationServicesMock"></param>
        /// <param name="configuration"></param>
        private static AutoMock Setup(
            Mock <IIoTHubConfigurationServices> ioTHubConfigurationServicesMock = null,
            IConfiguration configuration = null
            )
        {
            var mock = AutoMock.GetLoose(builder => {
                // Use empty configuration root if one is not passed.
                var conf = configuration ?? new ConfigurationBuilder()
                           .AddInMemoryCollection()
                           .Build();

                // Setup configuration
                builder.RegisterInstance(conf)
                .As <IConfiguration>()
                .SingleInstance();

                var containerRegistryConfig = new ContainerRegistryConfig(conf);
                builder.RegisterInstance(containerRegistryConfig)
                .AsImplementedInterfaces()
                .SingleInstance();

                // Setup JSON serializer
                builder.RegisterType <NewtonSoftJsonConverters>()
                .As <IJsonSerializerConverterProvider>();
                builder.RegisterType <NewtonSoftJsonSerializer>()
                .As <IJsonSerializer>();

                // Setup IIoTHubConfigurationServices mock
                if (ioTHubConfigurationServicesMock is null)
                {
                    var ioTHubConfigurationServices = new Mock <IIoTHubConfigurationServices>();
                    ioTHubConfigurationServices
                    .Setup(e => e.CreateOrUpdateConfigurationAsync(It.IsAny <ConfigurationModel>(), true, CancellationToken.None))
                    .Returns((ConfigurationModel configuration, bool forceUpdate, CancellationToken ct) => Task.FromResult(configuration));
                    builder.RegisterMock(ioTHubConfigurationServices);
                }
                else
                {
                    builder.RegisterMock(ioTHubConfigurationServicesMock);
                }

                builder.RegisterType <IoTHubDiscovererDeployment>()
                .AsSelf();;
            });

            return(mock);
        }