Documentation Coverage Report
Current view: top level - Cqrs.MongoDB.Tests.Integration - TestMongoDbDataStoreConnectionStringFactory.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 System.Runtime.Remoting.Messaging;
      11             : using cdmdotnet.StateManagement;
      12             : using cdmdotnet.StateManagement.Threaded;
      13             : using Cqrs.MongoDB.Factories;
      14             : 
      15             : namespace Cqrs.MongoDB.Tests.Integration
      16             : {
      17             :         /// <summary>
      18             :         /// A <see cref="IMongoDbDataStoreConnectionStringFactory"/>
      19             :         /// that enables you to set a database name with <see cref="DatabaseName"/>. This means you can randomly generate your own database name per test.
      20             :         /// </summary>
      21             :         public class TestMongoDataStoreConnectionStringFactory : IMongoDbDataStoreConnectionStringFactory
      22           1 :         {
      23             :                 private const string MongoDbConnectionStringKey = "MongoDb-Test";
      24             : 
      25             :                 private const string CallContextDatabaseNameKey = "MongoDataStoreConnectionStringFactory¿DatabaseName";
      26             : 
      27             :                 private static IContextItemCollection Query { get; set; }
      28             : 
      29             :                 static TestMongoDataStoreConnectionStringFactory()
      30             :                 {
      31             :                         Query = new ThreadedContextItemCollection();
      32             :                 }
      33             : 
      34             :                 /// <summary>
      35             :                 /// The name of the database currently being used.
      36             :                 /// </summary>
      37             :                 public static string DatabaseName
      38             :                 {
      39             :                         get
      40             :                         {
      41             :                                 return Query.GetData<string>(CallContextDatabaseNameKey);
      42             :                         }
      43             :                         set
      44             :                         {
      45             :                                 Query.SetData(CallContextDatabaseNameKey, value);
      46             :                         }
      47             :                 }
      48             : 
      49             :                 #region Implementation of IMongoDbDataStoreConnectionStringFactory
      50             : 
      51             :                 /// <summary>
      52             :                 /// Gets the current connection string named "MongoDb-Test"
      53             :                 /// </summary>
      54           1 :                 public string GetDataStoreConnectionString()
      55             :                 {
      56             :                         return ConfigurationManager.ConnectionStrings[MongoDbConnectionStringKey].ConnectionString;
      57             :                 }
      58             : 
      59             :                 /// <summary>
      60             :                 /// Gets the value of <see cref="DatabaseName"/>.
      61             :                 /// </summary>
      62           1 :                 public string GetDataStoreDatabaseName()
      63             :                 {
      64             :                         return DatabaseName;
      65             :                 }
      66             : 
      67             :                 #endregion
      68             :         }
      69             : }

Generated by: LCOV version 1.10