LCOV - code coverage report
Current view: top level - Cqrs/Services - EventService.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 5 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 System.Collections.Generic;
      11             : using cdmdotnet.Logging;
      12             : using Cqrs.Authentication;
      13             : using Cqrs.Events;
      14             : 
      15             : namespace Cqrs.Services
      16             : {
      17             :         public abstract class EventService<TAuthenticationToken> : IEventService<TAuthenticationToken>
      18           0 :         {
      19           0 :                 protected EventService(IEventStore<TAuthenticationToken> eventStore, ILogger logger, ICorrelationIdHelper correlationIdHelper, IAuthenticationTokenHelper<TAuthenticationToken> authenticationTokenHelper)
      20             :                 {
      21             :                         EventStore = eventStore;
      22             :                         Logger = logger;
      23             :                         CorrelationIdHelper = correlationIdHelper;
      24             :                         AuthenticationTokenHelper = authenticationTokenHelper;
      25             :                 }
      26             : 
      27             :                 protected virtual IEventStore<TAuthenticationToken> EventStore { get; private set; }
      28             : 
      29             :                 protected IAuthenticationTokenHelper<TAuthenticationToken> AuthenticationTokenHelper { get; private set; }
      30             : 
      31             :                 protected ICorrelationIdHelper CorrelationIdHelper { get; private set; }
      32             : 
      33             :                 protected ILogger Logger { get; private set; }
      34             : 
      35           0 :                 public virtual IServiceResponseWithResultData<IEnumerable<EventData>> GetEventData(IServiceRequestWithData<TAuthenticationToken, Guid> serviceRequest)
      36             :                 {
      37             :                         AuthenticationTokenHelper.SetAuthenticationToken(serviceRequest.AuthenticationToken);
      38             :                         CorrelationIdHelper.SetCorrelationId(serviceRequest.CorrelationId);
      39             : 
      40             :                         OnGetEventData(serviceRequest);
      41             :                         IEnumerable<EventData> results = EventStore.Get(serviceRequest.Data);
      42             :                         results = OnGotEventData(serviceRequest, results);
      43             : 
      44             :                         return new ServiceResponseWithResultData<IEnumerable<EventData>>
      45             :                         {
      46             :                                 State = ServiceResponseStateType.Succeeded,
      47             :                                 ResultData = results,
      48             :                                 CorrelationId = CorrelationIdHelper.GetCorrelationId()
      49             :                         };
      50             :                 }
      51             : 
      52           0 :                 protected virtual void OnGetEventData(IServiceRequestWithData<TAuthenticationToken, Guid> serviceRequest) { }
      53             : 
      54           0 :                 protected virtual IEnumerable<EventData> OnGotEventData(IServiceRequestWithData<TAuthenticationToken, Guid> serviceRequest, IEnumerable<EventData> results)
      55             :                 {
      56             :                         return results;
      57             :                 }
      58             :         }
      59             : }

Generated by: LCOV version 1.10