LCOV - code coverage report
Current view: top level - Azure/Cqrs.Azure.BlobStorage/DataStores - BlobStorageDataStore.cs Hit Total Coverage
Test: doc-coverage.info Lines: 2 4 50.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 System.Collections.Generic;
      11             : using System.Linq;
      12             : using cdmdotnet.Logging;
      13             : using Cqrs.DataStores;
      14             : using Cqrs.Entities;
      15             : 
      16             : namespace Cqrs.Azure.BlobStorage.DataStores
      17             : {
      18             :         public class BlobStorageDataStore<TData>
      19             :                 : BlobStorageStore<TData>
      20             :                 , IDataStore<TData>
      21             :                 where TData : Entity
      22           0 :         {
      23             :                 internal Func<string> GenerateFolderName { get; set; }
      24             : 
      25             :                 /// <summary>
      26             :                 /// Initializes a new instance of the <see cref="BlobStorage"/> class using the specified container.
      27             :                 /// </summary>
      28           1 :                 public BlobStorageDataStore(ILogger logger, IBlobStorageDataStoreConnectionStringFactory blobStorageDataStoreConnectionStringFactory)
      29             :                         : base(logger)
      30             :                 {
      31             :                         GetContainerName = blobStorageDataStoreConnectionStringFactory.GetBaseContainerName;
      32             :                         IsContainerPublic = blobStorageDataStoreConnectionStringFactory.IsContainerPublic<TData>;
      33             :                         GenerateFolderName = blobStorageDataStoreConnectionStringFactory.GetEntityName<TData>;
      34             :                         GenerateFileName = data => string.Format("{0}\\{1}", GenerateFolderName(), data.Rsn.ToString("N"));
      35             : 
      36             :                         // ReSharper disable DoNotCallOverridableMethodsInConstructor
      37             :                         Initialise(blobStorageDataStoreConnectionStringFactory);
      38             :                         // ReSharper restore DoNotCallOverridableMethodsInConstructor
      39             :                 }
      40             : 
      41             :                 #region Implementation of IDataStore<TData>
      42             : 
      43             :                 /// <summary>
      44             :                 /// Will mark the <paramref name="data"/> as logically (or soft).
      45             :                 /// </summary>
      46           1 :                 public void Remove(TData data)
      47             :                 {
      48             :                         data.IsLogicallyDeleted = true;
      49             :                         Update(data);
      50             :                 }
      51             : 
      52             :                 #endregion
      53             : 
      54           0 :                 public virtual IEnumerable<TData> GetByFolder()
      55             :                 {
      56             :                         string folderName = GenerateFolderName();
      57             :                         return OpenStreamsForReading(folderName: folderName)
      58             :                                 .Select(Deserialise);
      59             :                 }
      60             :         }
      61             : }

Generated by: LCOV version 1.10