Пример #1
0
        public virtual void TestFixtureSetUp()
        {
            _logger = NSubstitute.Substitute.For <ILog>();
            _eventStoreConnectionString = ConfigurationManager.ConnectionStrings["eventstore"].ConnectionString;;
            var url    = new MongoUrl(_eventStoreConnectionString);
            var client = new MongoClient(url);

            _db = client.GetDatabase(url.DatabaseName);
            _db.Drop();

            _identityConverter = new IdentityManager(new CounterService(_db));
            _identityConverter.RegisterIdentitiesFromAssembly(typeof(SampleAggregateId).Assembly);

            ProjectionEngineConfig config = new ProjectionEngineConfig()
            {
                EventStoreConnectionString = _eventStoreConnectionString
            };
            CommitEnhancer commitEnhancer = new CommitEnhancer(_identityConverter);

            sut = new EventUnwinder(config, NullLogger.Instance);

            _unwindedEventCollection = _db.GetCollection <UnwindedDomainEvent>("UnwindedEvents");
            MongoFlatMapper.EnableFlatMapping(true);
            MongoFlatIdSerializerHelper.Initialize(_identityConverter);
        }
        public virtual void TestFixtureSetUp()
        {
            _eventStoreConnectionString = ConfigurationManager.ConnectionStrings["eventstore"].ConnectionString;

            var url    = new MongoUrl(_eventStoreConnectionString);
            var client = new MongoClient(url);

            _db = client.GetDatabase(url.DatabaseName);
            _db.Drop();

            ProjectionEngineConfig config = new ProjectionEngineConfig();

            config.EventStoreConnectionString = _eventStoreConnectionString;
            config.Slots      = new string[] { "*" };
            config.TenantId   = new TenantId("A");
            config.BucketInfo = new List <BucketInfo>();
            config.BucketInfo.Add(new BucketInfo()
            {
                Slots = new[] { "*" }, BufferSize = 10000
            });

            _identityConverter = new IdentityManager(new CounterService(_db));
            _identityConverter.RegisterIdentitiesFromAssembly(typeof(SampleAggregateId).Assembly);
            ConfigureEventStore();
            CommitEnhancer commitEnhancer = new CommitEnhancer(_identityConverter);

            _eventUnwinder = new EventUnwinder(config, new TestLogger(LoggerLevel.Info));

            _unwindedEventCollection = _db.GetCollection <UnwindedDomainEvent>("UnwindedEvents");
            MongoFlatMapper.EnableFlatMapping(true);
            MongoFlatIdSerializerHelper.Initialize(_identityConverter);

            var rebuildContext = new RebuildContext(NitroEnabled);

            _storageFactory = new MongoStorageFactory(_db, rebuildContext);

            _reader1 = new MongoReader <SampleReadModel, string>(_db);
            _reader2 = new MongoReader <SampleReadModel2, string>(_db);
            _reader3 = new MongoReader <SampleReadModel3, string>(_db);

            //now configure RebuildProjectionEngine
            _tracker = new ConcurrentCheckpointTracker(_db);


            var projections = BuildProjections().ToArray();

            _tracker.SetUp(projections, 1, false);
            ProjectionEventInspector inspector = new ProjectionEventInspector();

            inspector.AddAssembly(Assembly.GetExecutingAssembly());
            sut        = new RebuildProjectionEngine(_eventUnwinder, _tracker, projections, rebuildContext, config, inspector);
            sut.Logger = new TestLogger(LoggerLevel.Debug);

            _checkpointCollection = _db.GetCollection <Checkpoint>("checkpoints");
        }
 public void SetUp()
 {
     _sut = new CommitEnhancer();
 }