LCOV - code coverage report
Current view: top level - Cqrs.MongoDB/Factories - MongoDbDataStoreConnectionStringFactory.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 4 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="cdmdotnet Limited">
       4             : // //   Copyright cdmdotnet Limited. All rights reserved.
       5             : // // </copyright>
       6             : // // -----------------------------------------------------------------------
       7             : #endregion
       8             : 
       9             : using System;
      10             : using Cqrs.Configuration;
      11             : using cdmdotnet.Logging;
      12             : 
      13             : namespace Cqrs.MongoDB.Factories
      14             : {
      15             :         public class MongoDbDataStoreConnectionStringFactory : IMongoDbDataStoreConnectionStringFactory
      16           0 :         {
      17             :                 public static string MongoDbConnectionStringKey = "CqrsMongoDb";
      18             : 
      19             :                 public static string MongoDbDatabaseNameKey = "CqrsMongoDbDatabaseName";
      20             : 
      21             :                 protected IConfigurationManager ConfigurationManager { get; private set; }
      22             : 
      23             :                 protected ILogger Logger { get; private set; }
      24             : 
      25           0 :                 public MongoDbDataStoreConnectionStringFactory(IConfigurationManager configurationManager, ILogger logger)
      26             :                 {
      27             :                         ConfigurationManager = configurationManager;
      28             :                         Logger = logger;
      29             :                 }
      30             : 
      31           0 :                 public string GetDataStoreConnectionString()
      32             :                 {
      33             :                         Logger.LogDebug("Getting MongoDB connection string", "MongoDataStoreConnectionStringFactory\\GetDataStoreConnectionString");
      34             :                         try
      35             :                         {
      36             :                                 return ConfigurationManager.GetSetting(MongoDbConnectionStringKey) ?? System.Configuration.ConfigurationManager.ConnectionStrings[MongoDbConnectionStringKey].ConnectionString;
      37             :                         }
      38             :                         catch (NullReferenceException exception)
      39             :                         {
      40             :                                 throw new NullReferenceException(string.Format("No connection string named '{0}' in the configuration file.", MongoDbConnectionStringKey), exception);
      41             :                         }
      42             :                         finally
      43             :                         {
      44             :                                 Logger.LogDebug("Getting MongoDB connection string... Done", "MongoDataStoreConnectionStringFactory\\GetDataStoreConnectionString");
      45             :                         }
      46             :                 }
      47             : 
      48           0 :                 public string GetDataStoreDatabaseName()
      49             :                 {
      50             :                         return ConfigurationManager.GetSetting(MongoDbDatabaseNameKey);
      51             :                 }
      52             :         }
      53             : }

Generated by: LCOV version 1.10