Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        public void ComponentRegistration_Reset_Success()
        {
            ComponentRegistration.Reset();
            var collector = ComponentRegistration.CreateInstance <ICollector>(ConfigurationTests.TYPE_COLLECTOR);

            collector.Should().NotBeNull();
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        // ReSharper restore UnassignedReadonlyField

        static AllComponents()
        {
            ComponentRegistration.Reset();

            ComponentRegistration.Initialize(() => Health);
            ComponentRegistration.Initialize(() => Name);
            ComponentRegistration.Initialize(() => Healing);
        }
Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 16
0
 public void Init()
 {
     ComponentRegistration.Reset();
 }