public void Log4NetFactoryTestWithExistingConfigFile()
        {
            const string configFile = "log4net.Test.config";
            Assert.IsTrue(File.Exists(configFile), "Test setup failure. Required log4net config file is missing.");

            Log4NetFactory factory = new Log4NetFactory(configFile);

            ILog log = factory.GetLogger(GetType());
            Assert.IsNotNull(log);
            Assert.IsNotNull(log as Log4NetLogger);
        }
        public void Log4NetFactoryTest()
        {
            Log4NetFactory factory = new Log4NetFactory();
            ILog log = factory.GetLogger(GetType());
            Assert.IsNotNull(log);
            Assert.IsNotNull(log as Log4NetLogger);

            factory = new Log4NetFactory(true);
            log = factory.GetLogger(GetType().Name);
            Assert.IsNotNull(log);
            Assert.IsNotNull(log as Log4NetLogger);
        }
Exemplo n.º 3
0
        public override void Configure(Funq.Container container)
        {
            #region Common Objects Registration

            JsConfig.DateHandler = JsonDateHandler.ISO8601;
            //Set JSON web services to return idiomatic JSON camelCase properties
            JsConfig.EmitCamelCaseNames = true;

            //Configure Logger
            log4net.Config.XmlConfigurator.Configure();
            ILogFactory _logFactory = new Log4NetFactory(true);
            ILog _logger = _logFactory.GetLogger(this.GetType());
            container.Register<ILog>(_logger);

            //Configure Connection Factory Provider
            string ConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
            IDbConnectionFactory _dbConnectionFactory = new OrmLiteConnectionFactory(ConnectionString, SqlServerOrmLiteDialectProvider.Instance);
            container.Register<IDbConnectionFactory>(_dbConnectionFactory);

            #endregion

            #region Repository Registration

            //Configure repositories
            IAlbumRepository _albumRepository = new AlbumRepository(_dbConnectionFactory, _logger);
            ISongRepository _songRepository = new SongRepository(_dbConnectionFactory, _logger);
            container.Register<IAlbumRepository>(_albumRepository);
            container.Register<ISongRepository>(_songRepository);

            #endregion

            #region Provider Registration

            //Configure providers
            IAlbumProvider _albumProvider = new AlbumProvider(_albumRepository, _logger);
            ISongProvider _songProvider = new SongProvider(_songRepository, _logger);
            container.Register<IAlbumProvider>(_albumProvider);
            container.Register<ISongProvider>(_songProvider);

            #endregion
        }