LCOV - code coverage report
Current view: top level - Cqrs.Tests/Substitutes - TestEventStore.cs Hit Total Coverage
Test: doc-coverage.info Lines: 0 7 0.0 %
Date: 2017-07-26

          Line data    Source code
       1             : using System;
       2             : using System.Collections.Generic;
       3             : using System.Linq;
       4             : using Cqrs.Events;
       5             : using Cqrs.Authentication;
       6             : 
       7             : namespace Cqrs.Tests.Substitutes
       8             : {
       9             :         public class TestEventStore : IEventStore<ISingleSignOnToken>
      10           0 :         {
      11           0 :                 public TestEventStore()
      12             :                 {
      13             :                         EmptyGuid = Guid.NewGuid();
      14             :                         SavedEvents = new List<IEvent<ISingleSignOnToken>>();
      15             :                 }
      16             : 
      17             :                 public Guid EmptyGuid { get; private set; }
      18             : 
      19           0 :                 public virtual void Save(Type aggregateRootType, IEvent<ISingleSignOnToken> @event)
      20             :                 {
      21             :                         SavedEvents.Add(@event);
      22             :                 }
      23             : 
      24           0 :                 public virtual IEnumerable<IEvent<ISingleSignOnToken>> Get<T>(Guid aggregateId, bool useLastEventOnly = false, int fromVersion = -1)
      25             :                 {
      26             :                         return Get(typeof(T),aggregateId, useLastEventOnly, fromVersion);
      27             :                 }
      28             : 
      29           0 :                 public virtual IEnumerable<IEvent<ISingleSignOnToken>> Get(Type aggregateType, Guid aggregateId, bool useLastEventOnly = false, int fromVersion = -1)
      30             :                 {
      31             :                         if (aggregateId == EmptyGuid || aggregateId == Guid.Empty)
      32             :                         {
      33             :                                 return new List<IEvent<ISingleSignOnToken>>();
      34             :                         }
      35             : 
      36             :                         return new List<IEvent<ISingleSignOnToken>>
      37             :                         {
      38             :                                 new TestAggregateDidSomething {Id = aggregateId, Version = 2},
      39             :                                 new TestAggregateDidSomethingElse {Id = aggregateId, Version = 3},
      40             :                                 new TestAggregateDidSomething {Id = aggregateId, Version = 4},
      41             :                         }
      42             :                         .Where(x => x.Version > fromVersion);
      43             :                 }
      44             : 
      45           0 :                 public IEnumerable<EventData> Get(Guid correlationId)
      46             :                 {
      47             :                         return Enumerable.Empty<EventData>();
      48             :                 }
      49             : 
      50           0 :                 public virtual void Save<T>(IEvent<ISingleSignOnToken> @event)
      51             :                 {
      52             :                         Save(typeof(T), @event);
      53             :                 }
      54             : 
      55             :                 private List<IEvent<ISingleSignOnToken>> SavedEvents { get; set; }
      56             :         }
      57             : }

Generated by: LCOV version 1.10