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

          Line data    Source code
       1             : using System;
       2             : using System.Collections.Generic;
       3             : using cdmdotnet.Logging;
       4             : using cdmdotnet.Logging.Configuration;
       5             : using Cqrs.Authentication;
       6             : using Cqrs.Bus;
       7             : using Cqrs.Commands;
       8             : using Cqrs.Configuration;
       9             : using Cqrs.Domain;
      10             : 
      11             : namespace Cqrs.Tests.Substitutes
      12             : {
      13             :         public class TestDependencyResolver : IDependencyResolver
      14           0 :         {
      15             :                 protected TestEventStore TestEventStore { get; private set; }
      16             : 
      17             :                 protected ICommandPublisher<ISingleSignOnToken> TestSingleSignOnTokenCommandPublisher { get; private set; }
      18             : 
      19             :                 public bool UseTestEventStoreGuid { get; set; }
      20             : 
      21             :                 public Guid? NewAggregateGuid { get; set; }
      22             : 
      23             :                 public readonly List<dynamic> Handlers = new List<dynamic>();
      24             : 
      25           0 :                 public TestDependencyResolver(TestEventStore testEventStore, ICommandPublisher<ISingleSignOnToken> testSingleSignOnTokenCommandPublisher = null)
      26             :                 {
      27             :                         TestEventStore = testEventStore;
      28             :                         TestSingleSignOnTokenCommandPublisher = testSingleSignOnTokenCommandPublisher;
      29             :                 }
      30             : 
      31           0 :                 public T Resolve<T>()
      32             :                 {
      33             :                         return (T)Resolve(typeof(T));
      34             :                 }
      35             : 
      36           0 :                 public object Resolve(Type type)
      37             :                 {
      38             :                         if (type == typeof(ILogger))
      39             :                                 return new ConsoleLogger(new LoggerSettings(), new NullCorrelationIdHelper());
      40             :                         if (type == typeof(IDependencyResolver))
      41             :                                 return this;
      42             :                         if (type == typeof(ICommandPublisher<ISingleSignOnToken>))
      43             :                                 return TestSingleSignOnTokenCommandPublisher;
      44             :                         if (type == typeof(IHandlerRegistrar) || type == typeof(IEventHandlerRegistrar) || type == typeof(ICommandHandlerRegistrar))
      45             :                                 return new TestHandleRegistrar();
      46             :                         if (type == typeof(ILogger))
      47             :                                 return new ConsoleLogger(new LoggerSettingsConfigurationSection(), new NullCorrelationIdHelper());
      48             :                         if (type == typeof (IConfigurationManager))
      49             :                                 return new ConfigurationManager();
      50             :                         if (type == typeof(TestAggregate))
      51             :                                 return new TestAggregate(TestEventStore == null || !UseTestEventStoreGuid ? NewAggregateGuid ?? Guid.NewGuid() : TestEventStore.EmptyGuid);
      52             :                         if (type == typeof(TestSaga))
      53             :                                 return new TestSaga(this, TestEventStore == null || !UseTestEventStoreGuid ? NewAggregateGuid ?? Guid.NewGuid() : TestEventStore.EmptyGuid);
      54             :                         if (type == typeof(TestSnapshotAggregate))
      55             :                                 return new TestSnapshotAggregate(TestEventStore == null || !UseTestEventStoreGuid ? NewAggregateGuid ?? Guid.NewGuid() : TestEventStore.EmptyGuid);
      56             :                         if (type == typeof(ISagaUnitOfWork<ISingleSignOnToken>) || type == typeof(ISagaUnitOfWork<Guid>))
      57             :                                 return new TestSagaUnitOfWork();
      58             :                         if (type == typeof(TestSagaEventHandlers))
      59             :                         {
      60             :                                 var handler = new TestSagaEventHandlers(this, Resolve<ILogger>());
      61             :                                 Handlers.Add(handler);
      62             :                                 return handler;
      63             :                         }
      64             :                         if (type == typeof(TestAggregateDidSomethingHandler))
      65             :                         {
      66             :                                 var handler = new TestAggregateDidSomethingHandler();
      67             :                                 Handlers.Add(handler);
      68             :                                 return handler;
      69             :                         }
      70             :                         else
      71             :                         {
      72             :                                 var handler = new TestAggregateDoSomethingHandler();
      73             :                                 Handlers.Add(handler);
      74             :                                 return handler;
      75             :                         }
      76             :                 }
      77             :         }
      78             : }

Generated by: LCOV version 1.10