protected override void Context()
        {
            _date = DateTime.Now;
            _commit = new Commit(Bucket.Default, streamId, 1, Guid.NewGuid(), 1, DateTime.Now, new LongCheckpoint(0).Value, null, null);

            _hook1 = A.Fake<IPipelineHook>();
            A.CallTo(() => _hook1.Select(_commit)).Returns(_commit);
            pipelineHooks.Add(_hook1);

            _hook2 = A.Fake<IPipelineHook>();
            A.CallTo(() => _hook2.Select(_commit)).Returns(_commit);
            pipelineHooks.Add(_hook2);

            A.CallTo(() => persistence.GetFrom(Bucket.Default, _date)).Returns(new List<ICommit> { _commit });
        }
            protected override Task Context()
            {
                _date = DateTime.Now;
                _commit = new Commit(Bucket.Default, streamId, 1, Guid.NewGuid(), 1, DateTime.Now, new LongCheckpoint(0).Value, null, null);

                //_hook1 = A.Fake<IPipelineHook>();
                //A.CallTo(() => _hook1.Select(_commit)).Returns(_commit);
                _hook1 = Substitute.For<IPipelineHook>();
                _hook1.Select(_commit).Returns(_commit);
                pipelineHooks.Add(_hook1);

                //_hook2 = A.Fake<IPipelineHook>();
                //A.CallTo(() => _hook2.Select(_commit)).Returns(_commit);
                _hook2 = Substitute.For<IPipelineHook>();
                _hook2.Select(_commit).Returns(_commit);
                pipelineHooks.Add(_hook2);

                //A.CallTo(() => persistence.GetFrom(Bucket.Default, _date)).Returns(new List<ICommit> {_commit}.AsAsyncEnumerable());
                persistence.GetFrom(Bucket.Default, _date).Returns(new List<ICommit> { _commit }.AsAsyncEnumerable());
                return Task.FromResult(true);
            }
 protected override Task Context()
 {
     _hook = Substitute.For<IPipelineHook>();
     pipelineHooks.Add(_hook);
     return Task.FromResult(true);
 }
 protected override void Context()
 {
     _hook = A.Fake<IPipelineHook>();
     pipelineHooks.Add(_hook);
 }
        public static Setup WithMongoEventStore(this Setup setup, string configConnectionKey, IPipelineHook hook, IDispatchCommits dispatcher, bool output)
        {
            var types = Assembly.GetAssembly(typeof(FreelanceManager.Events.Event))
                    .GetTypes()
                    .Where(type => type.IsClass && !type.ContainsGenericParameters)
                    .Where(type => type.IsSubclassOf(typeof(FreelanceManager.Events.Event)) ||
                                   type.Namespace.Contains("FreelanceManager.Dtos"));

            foreach (var t in types)
                BsonClassMap.LookupClassMap(t);

            BsonClassMap.LookupClassMap(typeof(Date));
            BsonClassMap.LookupClassMap(typeof(Time));
            BsonClassMap.LookupClassMap(typeof(Money));

            var eventStoreSetup = Wireup.Init()
                 .UsingMongoPersistence(configConnectionKey, new DocumentObjectSerializer())
                 .InitializeStorageEngine();

            if (output)
                eventStoreSetup.LogToOutputWindow();

            if (hook != null)
                eventStoreSetup.HookIntoPipelineUsing(hook);

            if (dispatcher != null)
                eventStoreSetup.UsingSynchronousDispatchScheduler()
                    .DispatchTo(dispatcher);


            var builder = new ContainerBuilder();
            builder.RegisterInstance<IStoreEvents>(eventStoreSetup.Build()).ExternallyOwned();
            builder.RegisterType<AggregateRootRepository>().As<IAggregateRootRepository>();
            builder.Update(setup.Container.ComponentRegistry);

            return setup;
        }
Exemplo n.º 6
0
 protected override Task Context()
 {
     _hook = A.Fake <IPipelineHook>();
     pipelineHooks.Add(_hook);
     return(Task.CompletedTask);
 }
 protected override void Context()
 {
     _hook = A.Fake <IPipelineHook>();
     pipelineHooks.Add(_hook);
 }