Documentation Coverage Report
Current view: top level - Ninject/Cqrs.Ninject.Mongo - TestMongoDataStoreConnectionStringFactory.cs Hit Total Coverage
Version: 2.2 Artefacts: 3 3 100.0 %
Date: 2017-09-22

          Line data    Source code
       1             : #region Copyright
       2             : // // -----------------------------------------------------------------------
       3             : // // <copyright company="Chinchilla Software Limited">
       4             : // //   Copyright Chinchilla Software Limited. All rights reserved.
       5             : // // </copyright>
       6             : // // -----------------------------------------------------------------------
       7             : #endregion
       8             : 
       9             : using System.Configuration;
      10             : using cdmdotnet.StateManagement;
      11             : using cdmdotnet.StateManagement.Threaded;
      12             : using Cqrs.Mongo.Factories;
      13             : 
      14             : namespace Cqrs.Ninject.Mongo
      15             : {
      16             :         /// <summary>
      17             :         /// A <see cref="IMongoDataStoreConnectionStringFactory"/>
      18             :         /// that enables you to set a database name with <see cref="DatabaseName"/>. This means you can randomly generate your own database name per test.
      19             :         /// </summary>
      20             :         public class TestMongoDataStoreConnectionStringFactory : IMongoDataStoreConnectionStringFactory
      21           1 :         {
      22             :                 private const string MongoDbConnectionStringKey = "MongoDb-Test";
      23             : 
      24             :                 private const string CallContextDatabaseNameKey = "MongoDataStoreConnectionStringFactory¿DatabaseName";
      25             : 
      26             :                 private static IContextItemCollection Query { get; set; }
      27             : 
      28             :                 static TestMongoDataStoreConnectionStringFactory()
      29             :                 {
      30             :                         Query = new ThreadedContextItemCollection();
      31             :                 }
      32             : 
      33             :                 /// <summary>
      34             :                 /// The name of the database currently being used.
      35             :                 /// </summary>
      36             :                 public static string DatabaseName
      37             :                 {
      38             :                         get
      39             :                         {
      40             :                                 return Query.GetData<string>(CallContextDatabaseNameKey);
      41             :                         }
      42             :                         set
      43             :                         {
      44             :                                 Query.SetData(CallContextDatabaseNameKey, value);
      45             :                         }
      46             :                 }
      47             :                 /// <summary>
      48             :                 /// Gets the current connection string.
      49             :                 /// </summary>
      50           1 :                 public string GetMongoConnectionString()
      51             :                 {
      52             :                         return ConfigurationManager.ConnectionStrings[MongoDbConnectionStringKey].ConnectionString;
      53             :                 }
      54             : 
      55             :                 /// <summary>
      56             :                 /// Gets the value of <see cref="DatabaseName"/>.
      57             :                 /// </summary>
      58           1 :                 public string GetMongoDatabaseName()
      59             :                 {
      60             :                         return DatabaseName;
      61             :                 }
      62             :         }
      63             : }

Generated by: LCOV version 1.10