public void TestInitialize() { NinjectDependencyResolver.ModulesToLoad.Clear(); // Core Module NinjectDependencyResolver.ModulesToLoad.Add(new CqrsModule <ISingleSignOnToken, SingleSignOnTokenValueHelper>()); // Event Store Module NinjectDependencyResolver.ModulesToLoad.Add(new InProcessEventStoreModule <ISingleSignOnToken>()); // Command Bus Module NinjectDependencyResolver.ModulesToLoad.Add(new InProcessCommandBusModule <ISingleSignOnToken>()); // Event Bus Module NinjectDependencyResolver.ModulesToLoad.Add(new InProcessEventBusModule <ISingleSignOnToken>()); // Domain Core Module NinjectDependencyResolver.ModulesToLoad.Add(new DomainCoreModule()); NinjectDependencyResolver.Start(); var corrolationIdHelper = NinjectDependencyResolver.Current.Resolve <ICorrolationIdHelper>(); corrolationIdHelper.SetCorrolationId(Guid.NewGuid()); var authenticationTokenHelper = NinjectDependencyResolver.Current.Resolve <IAuthenticationTokenHelper <ISingleSignOnToken> >(); var singleSignOnTokenFactory = NinjectDependencyResolver.Current.Resolve <ISingleSignOnTokenFactory>(); authenticationTokenHelper.SetAuthenticationToken(singleSignOnTokenFactory.CreateNew()); }
/// <summary> /// Starts the <see cref="AkkaNinjectDependencyResolver"/> /// </summary> /// <remarks> /// This exists so the static constructor can be triggered. /// </remarks> public new static void Start(IKernel kernel = null, bool prepareProvidedKernel = false) { // Create the ActorSystem and Dependency Resolver ActorSystem system = ActorSystem.Create("Cqrs"); Func <IKernel, NinjectDependencyResolver> originalDependencyResolverCreator = DependencyResolverCreator; Func <IKernel, NinjectDependencyResolver> dependencyResolverCreator = container => new AkkaNinjectDependencyResolver(container, system); if (originalDependencyResolverCreator == null) { DependencyResolverCreator = dependencyResolverCreator; } else { DependencyResolverCreator = container => { originalDependencyResolverCreator(container); return(dependencyResolverCreator(container)); } }; NinjectDependencyResolver.Start(kernel, prepareProvidedKernel); // Setup an actor that will handle deadletter type messages var deadletterWatchMonitorProps = Props.Create(() => new DeadletterToLoggerProxy(Current.Resolve <ILogger>())); var deadletterWatchActorRef = system.ActorOf(deadletterWatchMonitorProps, "DeadLetterMonitoringActor"); // subscribe to the event stream for messages of type "DeadLetter" system.EventStream.Subscribe(deadletterWatchActorRef, typeof(DeadLetter)); }
public void Should_load_events() { // Arrange NinjectDependencyResolver.ModulesToLoad.Add(new CqrsModule <int, DefaultAuthenticationTokenHelper>()); NinjectDependencyResolver.ModulesToLoad.Add(new SimplifiedSqlModule <int>()); NinjectDependencyResolver.ModulesToLoad.Add(new InProcessEventBusModule <int>()); NinjectDependencyResolver.Start(); var unitOfWork = new UnitOfWork <int>(DependencyResolver.Current.Resolve <ISnapshotAggregateRepository <int> >()); var aggregate = DependencyResolver.Current.Resolve <IAggregateFactory>().Create <TestAggregate>(Guid.NewGuid()); unitOfWork.Add(aggregate); int count = 0; do { aggregate.GenerateRandomNumber(); if (count % 10 == 0) { unitOfWork.Commit(); unitOfWork.Add(aggregate); } } while (count++ <= 20); unitOfWork.Commit(); // Act var aggregate2 = unitOfWork.Get <TestAggregate>(aggregate.Rsn); // Assert Assert.AreEqual(22, aggregate2.Version); Assert.AreEqual(aggregate.CurrentRandomNumber, aggregate2.CurrentRandomNumber); }
public void Start() { NinjectDependencyResolver.ModulesToLoad.Add(new THostModule()); NinjectDependencyResolver.ModulesToLoad.Add(new CqrsModule <ISingleSignOnToken, SingleSignOnTokenValueHelper>()); NinjectDependencyResolver.Start(); }
/// <summary> /// Starts the <see cref="AkkaNinjectDependencyResolver"/> /// </summary> /// <remarks> /// this exists to the static constructor can be triggered. /// </remarks> public new static void Start(IKernel kernel = null, bool prepareProvidedKernel = false) { // Create the ActorSystem and Dependency Resolver ActorSystem system = ActorSystem.Create("Cqrs"); DependencyResolverCreator = container => new AkkaNinjectDependencyResolver(container, system); NinjectDependencyResolver.Start(kernel, prepareProvidedKernel); }
protected override void StartResolver() { // NinjectDependencyResolver.Start(); var kernel = new StandardKernel(); // This is only done so the follow Wcf safe method can be called. Otherwise use the commented out line above. NinjectDependencyResolver.Start(kernel, true); BaseNinjectServiceHostFactory.SetKernel(kernel); }
public void Should_load_events() { // Arrange TestMongoDbSnapshotStoreConnectionStringFactory.DatabaseName = string.Format("Test-{0}", new Random().Next(0, 9999)); NinjectDependencyResolver.ModulesToLoad.Add(new CqrsModule <int, DefaultAuthenticationTokenHelper>()); NinjectDependencyResolver.ModulesToLoad.Add(new InProcessEventBusModule <int>()); NinjectDependencyResolver.ModulesToLoad.Add(new TestMongoDbModule <int>()); NinjectDependencyResolver.Start(); var unitOfWork = new UnitOfWork <int>(DependencyResolver.Current.Resolve <ISnapshotAggregateRepository <int> >()); var aggregate = DependencyResolver.Current.Resolve <IAggregateFactory>().Create <TestAggregate>(Guid.NewGuid()); unitOfWork.Add(aggregate); try { int count = 0; do { aggregate.GenerateRandomNumber(); if (count % 10 == 0) { unitOfWork.Commit(); unitOfWork.Add(aggregate); } } while (count++ <= 20); unitOfWork.Commit(); // Act var aggregate2 = unitOfWork.Get <TestAggregate>(aggregate.Rsn); // Assert Assert.AreEqual(22, aggregate2.Version); Assert.AreEqual(aggregate.CurrentRandomNumber, aggregate2.CurrentRandomNumber); } finally { // Clean-up TestMongoDataStoreConnectionStringFactory.DatabaseName = TestMongoDbSnapshotStoreConnectionStringFactory.DatabaseName; var factory = new TestMongoDbDataStoreFactory(DependencyResolver.Current.Resolve <ILogger>(), new TestMongoDataStoreConnectionStringFactory()); IMongoCollection <TestEvent> collection = factory.GetTestEventCollection(); collection.Database.Client.DropDatabase(TestMongoDataStoreConnectionStringFactory.DatabaseName); } }
/// <summary> /// Starts the <see cref="AkkaNinjectDependencyResolver"/> /// </summary> /// <remarks> /// This exists so the static constructor can be triggered. /// </remarks> public new static void Start(IKernel kernel = null, bool prepareProvidedKernel = false) { // Create the ActorSystem and Dependency Resolver ActorSystem system = ActorSystem.Create("Cqrs"); Func <IKernel, NinjectDependencyResolver> originalDependencyResolverCreator = DependencyResolverCreator; Func <IKernel, NinjectDependencyResolver> dependencyResolverCreator = container => new AkkaNinjectDependencyResolver(container, system); if (originalDependencyResolverCreator == null) { DependencyResolverCreator = dependencyResolverCreator; } else { DependencyResolverCreator = container => { originalDependencyResolverCreator(container); return(dependencyResolverCreator(container)); } }; NinjectDependencyResolver.Start(kernel, prepareProvidedKernel); }
protected virtual void StartResolver() { NinjectDependencyResolver.Start(); }