LCOV - code coverage report
Current view: top level - Cqrs.EventStore/Bus - EventStoreBasedLastEventProcessedStore.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 2 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : using System;
       2             : using Cqrs.Bus;
       3             : using EventStore.ClientAPI;
       4             : 
       5             : namespace Cqrs.EventStore.Bus
       6             : {
       7             :         public class EventStoreBasedLastEventProcessedStore : IStoreLastEventProcessed
       8           0 :         {
       9             :                 public const string EventsProcessedStreamName = @"EventsProcessed";
      10             : 
      11             :                 public const string EventType = @"ProcessedEvent";
      12             : 
      13             :                 protected IEventStoreConnection EventStoreConnection { get; private set; }
      14             : 
      15           0 :                 public EventStoreBasedLastEventProcessedStore(IEventStoreConnection eventStoreConnection)
      16             :                 {
      17             :                         if (eventStoreConnection == null)
      18             :                         {
      19             :                                 throw new ArgumentNullException("eventStoreConnection");
      20             :                         }
      21             : 
      22             :                         EventStoreConnection = eventStoreConnection;
      23             :                 }
      24             : 
      25             :                 public string EventLocation
      26             :                 {
      27             :                         get
      28             :                         {
      29             :                                 StreamEventsSlice slice = EventStoreConnection.ReadStreamEventsBackwardAsync(EventsProcessedStreamName, StreamPosition.End, 1, false).Result;
      30             :                                 if (slice.Events.Length > 0)
      31             :                                 {
      32             :                                         return EventStoreUtilities.ByteArrayToString(slice.Events[0].Event.Data);
      33             :                                 }
      34             : 
      35             :                                 return string.Empty;
      36             :                         }
      37             :                         set
      38             :                         {
      39             :                                 var eventData = new EventData(Guid.NewGuid(), EventType, false, EventStoreUtilities.StringToByteArray(value), null);
      40             :                                 EventStoreConnection.AppendToStreamAsync(EventsProcessedStreamName, ExpectedVersion.Any, new [] { eventData }).RunSynchronously();
      41             :                         }
      42             :                 }
      43             :         }
      44             : }

Generated by: LCOV version 1.10