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             :                         if (aggregateType == typeof (TestSaga))
      37             :                         {
      38             :                                 return new List<ISagaEvent<ISingleSignOnToken>>
      39             :                                 {
      40             :                                         new SagaEvent<ISingleSignOnToken>
      41             :                                         (
      42             :                                                 new TestAggregateDidSomethingElse {Id = Guid.NewGuid(), Version = 13}
      43             :                                         ){Id = aggregateId, Version = 2},
      44             :                                         new SagaEvent<ISingleSignOnToken>
      45             :                                         (
      46             :                                                 new TestAggregateDidSomething {Id = Guid.NewGuid(), Version = 26}
      47             :                                         ){Id = aggregateId, Version = 3},
      48             :                                         new SagaEvent<ISingleSignOnToken>
      49             :                                         (
      50             :                                                 new TestAggregateDidSomething {Id = Guid.NewGuid(), Version = 47}
      51             :                                         ){Id = aggregateId, Version = 4}
      52             :                                 }
      53             :                                 .Where(x => x.Version > fromVersion);
      54             :                         }
      55             :                         return new List<IEvent<ISingleSignOnToken>>
      56             :                         {
      57             :                                 new TestAggregateDidSomething {Id = aggregateId, Version = 2},
      58             :                                 new TestAggregateDidSomethingElse {Id = aggregateId, Version = 3},
      59             :                                 new TestAggregateDidSomething {Id = aggregateId, Version = 4}
      60             :                         }
      61             :                         .Where(x => x.Version > fromVersion);
      62             :                 }
      63             : 
      64           0 :                 public IEnumerable<EventData> Get(Guid correlationId)
      65             :                 {
      66             :                         return Enumerable.Empty<EventData>();
      67             :                 }
      68             : 
      69           0 :                 public virtual void Save<T>(IEvent<ISingleSignOnToken> @event)
      70             :                 {
      71             :                         Save(typeof(T), @event);
      72             :                 }
      73             : 
      74             :                 private List<IEvent<ISingleSignOnToken>> SavedEvents { get; set; }
      75             :         }
      76             : }

Generated by: LCOV version 1.10