示例#1
0
        public void Init()
        {
            ComponentRegistration.Reset();

            ComponentRegistration.RegisterComponent <IMapper>(ConfigurationTests.TYPE_MAPPER);
            ComponentRegistration.RegisterComponent <IStack>(ConfigurationTests.TYPE_STACK);
            ComponentRegistration.RegisterComponent <IConverter>(ConfigurationTests.TYPE_CONVERTER);
            ComponentRegistration.RegisterComponent <IEntity>(ConfigurationTests.TYPE_DATA);
            ComponentRegistration.RegisterComponent <ITransformedDataHandler>(ConfigurationTests.TYPE_TRANSFORMATION_HANDLER);

            ComponentRegistration.RegisterComponent <ICollector>(TYPE_FOLDER_MONITOR_COLLECTOR);
            ComponentRegistration.RegisterComponent <IPublisher>(TYPE_LOG_PUBLISHER);
            ComponentRegistration.RegisterComponent <ITransformer>(TYPE_SAMPLE_TRANSFORMER);
            ComponentRegistration.RegisterComponent <IDirectory>(TYPE_SAMPLE_DIRECTORY);

            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = ConfigurationTests.COLLECTOR_SDK_ASSEMBLY,
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = ConfigurationTests.NLOG_EXTRAS_ASSEMBLY,
                RegisterAll  = true
            });

            ComponentRegistration.Build();
        }
示例#2
0
        public void Init()
        {
            ComponentRegistration.Reset();

            ComponentRegistration.RegisterSingletonComponent <ICollector>(ConfigurationTests.TYPE_COLLECTOR);
            ComponentRegistration.RegisterComponent <IStack>(ConfigurationTests.TYPE_STACK);
            ComponentRegistration.RegisterComponent <IConverter>(ConfigurationTests.TYPE_CONVERTER);
            ComponentRegistration.RegisterComponent <IReader>(ConfigurationTests.TYPE_READER);
            ComponentRegistration.RegisterComponent <ITransformer>(ConfigurationTests.TYPE_TRANSFORMER);
            ComponentRegistration.RegisterComponent <IPublisher>(ConfigurationTests.TYPE_PUBLISHER);
            ComponentRegistration.RegisterComponent <IMapper>(ConfigurationTests.TYPE_MAPPER);
            ComponentRegistration.RegisterComponent <IEntity>(ConfigurationTests.TYPE_DATA);

            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = ConfigurationTests.COLLECTOR_SDK_ASSEMBLY,
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = ConfigurationTests.NLOG_EXTRAS_ASSEMBLY,
                RegisterAll  = true
            });

            ComponentRegistration.Build();
        }
示例#3
0
        public void SingletonRegistration_Fails_Without_Singleton_Flag()
        {
            var readers = new List <ReaderConfiguration>();

            readers.Add(CreateReaderWithSingletonDependencyConfig("1", "2"));

            ComponentRegistration.Reset();
            // the collector needs to be registered since it is injected
            ComponentRegistration.RegisterComponent <ICollector>(ConfigurationTests.TYPE_COLLECTOR);
            ComponentRegistration.RegisterComponents(readers);
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = COLLECTOR_SDK_ASSEMBLY,
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = NLOG_EXTRAS_ASSEMBLY,
                RegisterAll  = true
            });
            ComponentRegistration.Build();

            IReader reader = null;

            Assert.ThrowsException <DependencyResolutionException>(() => reader = ComponentRegistration.CreateInstance <IReader>(ConfigurationTests.TYPE_READER_WITH_SINGLETON_DEPENDENCY));
            reader.Should().BeNull();
        }
示例#4
0
        public void TransformerRegistration_Success()
        {
            var transformers = new List <TransformerConfiguration>();

            transformers.Add(CreateTransformerConfig("1", CreateMapperConfig("2", "1"), "3"));

            ComponentRegistration.Reset();
            // the collector needs to be resgistered since it is injected
            ComponentRegistration.RegisterComponent <ICollector>(ConfigurationTests.TYPE_COLLECTOR);
            ComponentRegistration.RegisterComponents(transformers);
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = COLLECTOR_SDK_ASSEMBLY,
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = NLOG_EXTRAS_ASSEMBLY,
                RegisterAll  = true
            });
            ComponentRegistration.Build();
            var reader = ComponentRegistration.CreateInstance <ITransformer>(ConfigurationTests.TYPE_TRANSFORMER);

            reader.Should().NotBeNull();
        }
示例#5
0
        public void Init()
        {
            File.Delete(_path);

            ComponentRegistration.Reset();
            ComponentRegistration.RegisterComponent <ILogger>(TYPE_LOGGER);
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Autofac.Extras.NLog",
                RegisterAll  = true
            });
            ComponentRegistration.Build();

            var config  = new NLog.Config.LoggingConfiguration();
            var logfile = new NLog.Targets.FileTarget()
            {
                FileName = _path, Name = "logfile"
            };
            var logconsole = new NLog.Targets.ConsoleTarget()
            {
                Name = "logconsole"
            };

            config.LoggingRules.Add(new NLog.Config.LoggingRule("*", LogLevel.Info, logconsole));
            config.LoggingRules.Add(new NLog.Config.LoggingRule("*", LogLevel.Debug, logfile));
            LogManager.Configuration = config;
        }
示例#6
0
        public void SingletonRegistration_Build_Success()
        {
            var readers = new List <ReaderConfiguration>();

            readers.Add(CreateReaderWithSingletonDependencyConfig("1", "2"));

            ComponentRegistration.Reset();
            // the collector needs to be registered since it is injected
            ComponentRegistration.RegisterComponent <ICollector>(ConfigurationTests.TYPE_COLLECTOR);
            ComponentRegistration.RegisterComponents(readers);
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = COLLECTOR_SDK_ASSEMBLY,
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = typeof(MockDisposableSingleton).Assembly.GetName().Name,
                Type         = nameof(MockDisposableSingleton),
                Singleton    = true
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = NLOG_EXTRAS_ASSEMBLY,
                RegisterAll  = true
            });
            ComponentRegistration.Build();
            var reader = ComponentRegistration.CreateInstance <IReader>(ConfigurationTests.TYPE_READER_WITH_SINGLETON_DEPENDENCY);

            reader.Should().NotBeNull();
        }
        public void Init()
        {
            ComponentRegistration.Reset();

            ComponentRegistration.RegisterComponent <ICollector>(ConfigurationTests.TYPE_COLLECTOR);
            ComponentRegistration.RegisterComponent <IStack>(ConfigurationTests.TYPE_STACK);
            ComponentRegistration.RegisterComponent <IConverter>(ConfigurationTests.TYPE_CONVERTER);
            ComponentRegistration.RegisterComponent <IReader>(ConfigurationTests.TYPE_READER);
            ComponentRegistration.RegisterComponent <ITransformer>(ConfigurationTests.TYPE_TRANSFORMER);
            ComponentRegistration.RegisterComponent <ITransformedDataHandler>(ConfigurationTests.TYPE_TRANSFORMATION_HANDLER);
            ComponentRegistration.RegisterComponent <IPublisher>(ConfigurationTests.TYPE_PUBLISHER);
            ComponentRegistration.RegisterComponent <IMapper>(ConfigurationTests.TYPE_MAPPER);
            ComponentRegistration.RegisterComponent <IEntity>(ConfigurationTests.TYPE_DATA);

            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Collector.SDK",
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Autofac.Extras.NLog",
                RegisterAll  = true
            });

            ComponentRegistration.Build();
        }
        public void ReaderRegistration_Success()
        {
            var readers = new List <ReaderConfiguration>();

            readers.Add(CreateReaderConfig("1", "2"));

            ComponentRegistration.Reset();
            // the collector needs to be resgistered since it is injected
            ComponentRegistration.RegisterComponent <ICollector>(ConfigurationTests.TYPE_COLLECTOR);
            ComponentRegistration.RegisterComponents(readers);
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Collector.SDK",
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Autofac.Extras.NLog",
                RegisterAll  = true
            });
            ComponentRegistration.Build();
            var reader = ComponentRegistration.CreateInstance <IReader>(ConfigurationTests.TYPE_READER);

            reader.Should().NotBeNull();
        }
示例#9
0
        /// <summary>
        /// Create a Collector, this involved creating all the layers - Readers, Transformers and Publishers.
        /// </summary>
        /// <param name="collectorConfig">The configuration that defines all the layers.</param>
        /// <param name="mapperConfigs">The mappers to use by transformers.</param>
        /// <returns></returns>
        public static ICollector CreateCollector(CollectorConfiguration collectorConfig)
        {
            ComponentRegistration.RegisterComponents(collectorConfig);
            ComponentRegistration.Build();

            var collector = ComponentRegistration.CreateInstance <ICollector>(collectorConfig.Type);

            collector.Configure(collectorConfig);
            return(collector);
        }
示例#10
0
        /// <summary>
        /// Create an array of collectors
        /// </summary>
        /// <param name="collectorConfigs">An array of collector configurations</param>
        /// <returns>a list of collectors</returns>
        public static List <ICollector> CreateCollectors(CollectorConfiguration[] collectorConfigs)
        {
            var result = new List <ICollector>();

            foreach (var config in collectorConfigs)
            {
                ComponentRegistration.RegisterComponents(config);
            }
            ComponentRegistration.Build();
            foreach (var config in collectorConfigs)
            {
                var collector = ComponentRegistration.CreateInstance <ICollector>(config.Type);
                collector.Configure(config);
                result.Add(collector);
            }
            return(result);
        }
示例#11
0
 public void Init()
 {
     ComponentRegistration.Reset();
     ComponentRegistration.RegisterComponent <IEntity>(TYPE_MOCKUSER);
     ComponentRegistration.RegisterComponent <IConverter>(TYPE_DATE_TIME_COMBINE_CONVERTER);
     ComponentRegistration.RegisterComponent <IConverter>(TYPE_DATE_TIME_UTC_CONVERTER);
     ComponentRegistration.RegisterComponent <IConverter>(TYPE_UPPER_CASE_CONVERTER);
     ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
     {
         AssemblyName = ConfigurationTests.COLLECTOR_SDK_ASSEMBLY,
         Type         = "LoggerFacade"
     });
     ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
     {
         AssemblyName = ConfigurationTests.NLOG_EXTRAS_ASSEMBLY,
         RegisterAll  = true
     });
     ComponentRegistration.Build();
 }
示例#12
0
 public void Init()
 {
     ComponentRegistration.Reset();
     ComponentRegistration.RegisterComponent <IEntity>(TYPE_MOCKUSER);
     ComponentRegistration.RegisterComponent <IConverter>(TYPE_DATE_TIME_COMBINE_CONVERTER);
     ComponentRegistration.RegisterComponent <IConverter>(TYPE_DATE_TIME_UTC_CONVERTER);
     ComponentRegistration.RegisterComponent <IConverter>(TYPE_UPPER_CASE_CONVERTER);
     ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
     {
         AssemblyName = "Collector.SDK",
         Type         = "LoggerFacade"
     });
     ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
     {
         AssemblyName = "Autofac.Extras.NLog",
         RegisterAll  = true
     });
     ComponentRegistration.Build();
 }
示例#13
0
        public void CollectorRegistration_Success()
        {
            ComponentRegistration.Reset();
            ComponentRegistration.RegisterComponents(CreateCollectorConfig("1"));
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = COLLECTOR_SDK_ASSEMBLY,
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = NLOG_EXTRAS_ASSEMBLY,
                RegisterAll  = true
            });
            ComponentRegistration.Build();
            var collector = ComponentRegistration.CreateInstance <ICollector>(ConfigurationTests.TYPE_COLLECTOR);

            collector.Should().NotBeNull();
        }
示例#14
0
        public void MapperRegistration_Success()
        {
            ComponentRegistration.Reset();
            ComponentRegistration.RegisterComponent(CreateMapperConfig("1", "2"));
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Collector.SDK",
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Autofac.Extras.NLog",
                RegisterAll  = true
            });
            ComponentRegistration.Build();
            var mapper = ComponentRegistration.CreateInstance <IMapper>(ConfigurationTests.TYPE_MAPPER);

            mapper.Should().NotBeNull();
        }
示例#15
0
        public void ComponentRegistration_Build_Success()
        {
            ComponentRegistration.Reset();
            ComponentRegistration.RegisterComponent <ICollector>(ConfigurationTests.TYPE_COLLECTOR);
            ComponentRegistration.RegisterTypesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Collector.SDK",
                Type         = "LoggerFacade"
            });
            ComponentRegistration.RegisterModulesFromAssembly(new ThirdPartyAutofacConfiguration()
            {
                AssemblyName = "Autofac.Extras.NLog",
                RegisterAll  = true
            });
            ComponentRegistration.Build();

            var collector = ComponentRegistration.CreateInstance <ICollector>(ConfigurationTests.TYPE_COLLECTOR);

            collector.Should().NotBeNull();
        }