Documentation Coverage Report
Current view: top level - Cqrs.MongoDB.Tests.Integration - TestMongoDbSnapshotStoreConnectionStringFactory.cs Hit Total Coverage
Version: 2.2 Artefacts: 3 3 100.0 %
Date: 2018-08-07 15:04:50

          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.MongoDB.Events;
      13             : 
      14             : namespace Cqrs.MongoDB.Tests.Integration
      15             : {
      16             :         /// <summary>
      17             :         /// A <see cref="IMongoDbEventStoreConnectionStringFactory"/>
      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 TestMongoDbSnapshotStoreConnectionStringFactory : IMongoDbSnapshotStoreConnectionStringFactory
      21           1 :         {
      22             :                 private static IContextItemCollection Query { get; set; }
      23             : 
      24             :                 static TestMongoDbSnapshotStoreConnectionStringFactory()
      25             :                 {
      26             :                         Query = new ThreadedContextItemCollection();
      27             :                 }
      28             : 
      29             :                 /// <summary>
      30             :                 /// The name of the database currently being used.
      31             :                 /// </summary>
      32             :                 public static string DatabaseName
      33             :                 {
      34             :                         get
      35             :                         {
      36             :                                 return Query.GetData<string>(TestMongoEventStoreConnectionStringFactory.CallContextDatabaseNameKey);
      37             :                         }
      38             :                         set
      39             :                         {
      40             :                                 Query.SetData(TestMongoEventStoreConnectionStringFactory.CallContextDatabaseNameKey, value);
      41             :                         }
      42             :                 }
      43             : 
      44             :                 #region Implementation of IMongoDbSnapshotStoreConnectionStringFactory
      45             : 
      46             :                 /// <summary>
      47             :                 /// Gets the current connection string.
      48             :                 /// </summary>
      49           1 :                 public string GetSnapshotStoreConnectionString()
      50             :                 {
      51             :                         return ConfigurationManager.ConnectionStrings[TestMongoEventStoreConnectionStringFactory.MongoDbConnectionStringKey].ConnectionString;
      52             :                 }
      53             : 
      54             :                 /// <summary>
      55             :                 /// Gets the current database name.
      56             :                 /// </summary>
      57           1 :                 public string GetSnapshotStoreDatabaseName()
      58             :                 {
      59             :                         return DatabaseName;
      60             :                 }
      61             : 
      62             :                 #endregion
      63             :         }
      64             : }

Generated by: LCOV version 1.12